提问:这个主函数怎么调用上面的三个函数啊,我不大会
网友回答:
你的调用顺序不正确,且函数本身也有问题,要调用函数,你的变量要定义在main中
改好的参考
#include<stdio.h>
#include <string.h>
void inpot(char str[])
{
char c;
printf("ÇëÊäÈëÒ»´®×Ö·û:");
gets(str);
}
void count(char *p)
{
int a=0,b=0,c=0,d=0,e=0;
while(*p!='\0')
{
if('A'<=*p&&*p<='Z')
{
a++;
}
else if('a'<=*p&&*p<='z')
{
b++;
}
else if(*p==' ')
{
c++;
}
else if('0'<=*p&&*p<='9')
{
d++;
}
else
{
e++;
}
p++;
}
printf("´óд×ÖĸÊý:%d\nСд×ÖĸÊý:%d\n¿Õ¸ñÊý:%d\nÊý×ÖÊý:%d\nÆäËû:%d\n",a,b,c,d,e);
}
void outpot(char str[])
{
puts(str);
}
int main(void)
{
char str[100];
inpot(str);
outpot(str);
count(str);
return 0;
}