I want to make a function slen (recursive) with arguments a pointer to string and returns the length of the string.I make this but i have segmetation fault.
any idea?
Code:
#include <stdio.h> int slen(char *p); int main(void) { char *s="hello"; int num; num=slen(s); printf("%d\n", num); return 0; } int slen(char *p) { if (*p=='\0') return 0; else return(slen(p++) +1); }
Comment