I do not think your example is meaningful, you use length , which already returns the length of your calculation. If I were your mentor, I would not accept this as an acceptable solution.
You probably need to use const char*
int count(const char* s){ if(*s == '\0') return 0; return 1 + count(s + 1); }
user1773602
source share