返回字符串的长度

int func(char *str)
{
 assert(str != NULL);
 while(*str != '\0')
 {

 // return (func(str+1))+1;
  return (func(str++))+1;   //为什么不行?
 // return (func(++str))+1;
 }

}

void main()
{


 char* str = "Hello,World";
 int k = func(str);
 cout<<k<<endl;

原文地址:https://www.cnblogs.com/CBDoctor/p/2775401.html