I'm kida new to the recursion subject and i've been trying to write the "strlen" function using recurion, thats what i tried:
int strlen ( char str[], int i)
{
if ( str[i] == 0) return i+1;
return strlen(str,i++);
}
and i tried something very similiar
int strlen( char str[], int i)
{
if ( str[i] == 0) return 1;
return strlen(str,i++) + 1;
}
and in my main function
int main()
{
char word[MAX_DIGITS];
scanf("%s",word);
printf("%d", strlen(word,0));
return 0;
}
but my program would crash whenever i run it, what am I missing? (I'm using C90 btw)