求字符个数问题
程序如下:#include"stdio.h"
main()
{
void strle(char *p);
char array;
gets(array);
strle(array);
}
void strle(char *p)
{
int i=0;
char *p1;
for(p1=p;p1!='\0';p1++)
i++;
printf("the answer is %d\n",i);
}
为什么这样做错呢,请问应该怎么写才正确呢? #include<stdio.h>
void main()
{
void strle(char *p);
char array;
gets(array);
strle(array);
}
void strle(char *p)
{
int i=0;
char *p1=p;
for(*p1=*p;*p1!='\\0';*p1++)
i++;
printf("the answer is %d\\n",i);
} #include"stdio.h"
main()
{
void strle(char *p);
char array;
gets(array);
strle(array);
}
void strle(char *p)
{
int i=0;
char *p1;
for(p1=p;*p1!='\\0';p1++)
i++;
printf("the answer is %d\\n",i);
}
楼上有部分写错了......
页:
[1]