C语言:编程求一个字符串的长度, 用字符数组实现。(麻烦大神帮忙解答下)

main()
{ int len=0;
char str[20], *p;
printf("\nInput a string:");
scanf("%s",str);
p=str;
while (*p!='\0')
{ len++;
【 】; /*字符串指针自增*/
}
printf("\nThe lengthis:%d",【 】);
}

main()
{ int len=0;
  char str[20], *p;
  printf("\nInput a string:");
  scanf("%s",str);
  p=str;
  while (*p!='\0')
   {  len++;
      p++;          /*字符串指针自增*/
   }
  printf("\nThe lengthis:%d",len);
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-06-16
第一个空:p++;
第二个空:len
相似回答