D:尀c++尀c程序尀11尀1.cpp(9) : error C2137: empty character constant

char string[81];
2025-04-16 13:20:22
推荐回答(2个)
回答1:

你好!!
把你的代码发来看看!!

#include
#include
void main()
{
char string[81];
int i,num=0 ,word=0;
char c;
gets(string);
for(i=0;(c=string[i])!='\0';i++)
if(isspace(c)) //使用库函数
word=0;
else if(word ==0)
{
word=1;
num++;

}
printf("there are %d words in the line.\n",num);

}

测试:
kdjf dkf dkf
there are 3 words in the line.
Press any key to continue

回答2:

string好像不能用做名称使用的吧
直接用string类型不就好了