Written questions:
Do not use intermediate variables to find the const string length, that is, the implementation of String length library function strlen function.
The function interface is declared as follows: int My_strlen (const char *p);
The actual function of the strlen function is to iterate from the first address representing the string until it encounters the Terminator ' \ S '.
The size of the returned length does not include ' + '.
#include <stdio.h> #include <assert.h>//uses intermediate variables//int my_strlen (const char *str)//{//assert (str);//int cou NT = 0;//while (*str++)//{//count++;//}//return count;//}//recursive method (do not use intermediate variable) int my_strlen (const char *STR) {if (*str = = ')} {return 0;} Else{return 1 + my_strlen (str + 1);}} int main () {char str[] = {0};gets (str); int len = My_strlen (str);p rintf ("%d\n", Len); System ("pause"); return 0;}
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/75/D6/wKioL1ZDSiaSCUhhAAApZBzGzpw986.png "title=" 3.png " alt= "Wkiol1zdsiascuhhaaapzbzgzpw986.png"/>
Written question: Do not use intermediate variables to find the const string length, that is, the implementation of String length library function strlen function