求助C语言问题,各位朋友帮忙看下哪错了,运行不了,

来源:百度知道 编辑:UC知道 时间:2024/05/26 10:52:48
2. 输入一行字符,统计其中有多少个单词,单词之间用空格分隔开。
程序如下:
#include<stdio.h>
main()
{
char string[81];
int i,num=0,word=0;
char c;
gets(string);
for(i=0; (c=string[i])!='\0';i++)
if(c==“ ”)word=0;
else if(word==0)
{
word=1;
num++;
}
printf(“There are %d words in the line.\n”,num);
}

#include<stdio.h>
main()
{
char string[81];
int i,num=0,word=0;
char c;
gets(string);
for(i=0;(c=string[i])!='\0';i++)
if(c==' ')word=0;
else if(word==0)
{
word=1;
num++;
}
printf("There are %d words in the line.\n",num);
}
//修改如上 注意程序中的标点符号要是英文的 即可