strlen function using recursion in c

后端 未结 4 1331
离开以前
离开以前 2021-01-26 11:17

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         


        
4条回答
  •  -上瘾入骨i
    2021-01-26 12:15

    return strlen(str,i++);
    

    You are using the wrong increment operator. i++ means the original value of i is passed as argument, and then it's incremented. That means infinite recursion.

    You should try ++i instead, or better, i + 1.

提交回复
热议问题