#recursion problem

7 messages · Page 1 of 1 (latest)

paper hound
#
int caps(char *str) {
   if(str != NULL){
      if(isupper(*str)){
         return 1 + caps(str + 1);
      }
      else{
         caps(str+1);
      }
   }
   else{
      return 0;
   }
}

working on a recursion problem for homework and this is what I have so far but is giving a core dump, some help would be appreciated

modern kayakBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

paper hound
#

wait i believe ive done it with ```c
if(*str != NULL){

#

odd that it gives me a warning but works

tulip dagger
#

str + 1 will never point to null

#

strings are null terminated though, which is essentially what *str != NULL checks

paper hound
#

!solved