Analyzing pointer string length

Description Questions
enter a string. The method requires the use of pointers to traverse the string, and counts the length of the string. Not allowed to use strlen () function.
Enter
Enter a string, no more than 999 characters, ending with a carriage return.
Output
the output length of the string.
Examples of input
apple
output example
5
data range
input character string, the output is an integer. And the input string no more than 999 characters

#include "stdio.h"
void main()
{
char s[999],*p;
int i=0,flag=1;
gets(s);
for(p=s;*p!='\0';*p++)
{
i++;
}

printf("%d",i);


}

Guess you like

Origin blog.csdn.net/Lhw_666/article/details/91415236