219. recursive function for strlengh
Microsoft Interview Questions and Answers
(Continued from previous question...)
219. recursive function for strlengh
Question:
recursive function for strlengh
maybe an answer:
int strlength(char *s){
++s;
return ((s[0]=='\0')?1:(1 + strlength(s)));
}
maybe an answer2:
int xStrLen(char * str)
{
if(!(*str))
return 0;
int res = xStrLen(++str) + 1;
return res;
}
(Continued on next question...)
Other Interview Questions
|