#include<stdio.h>
main()
{
char string[100];
int index,word=1;
char blank;
gets(string);
if(string[0]==‘\0‘)
{
printf("there is no char!\n");
}
else if(string[0]==‘ ‘)
{
printf("first char just is a blank!\n");
}
else
{
for(index=0;string[index]!=0;index++)
{
blank=string[index];
if(blank==‘ ‘)
{
word++;
}
}
printf("%d\n",word);
}
return 0;
}
原文地址:https://www.cnblogs.com/redxi/p/10836041.html
时间: 2024-11-06 20:20:07