编译器是 Visual Studio 2010
运行时弹出警示框,提示words变量在未被初始化的情况下被使用。
int main ()
{
char article[5000];
char words[500][20];
char sentences[100][100];
int countSentences=0;
int countWords=0;
char *count;
char *temp;
cout<<"请输入需要解析的英语文章:";
cin.getline(article,5000);
count=article;
temp=article;
for(int i=0;*temp!=' ';temp++,i++)
words[0][i]=*temp;
for(;*count;count++)
{
if (*count==' ') countWords++;
else if (*count=='?'||*count=='.'||*count=='!') countSentences++;
}
countWords++;
cout<<"共计 "<<countWords<<" 个英语单词"<<endl;
cout<<"共计 "<<countSentences<<" 个句子"<<endl;
cout<<*words[0]<<endl;
}
C++小白,指针的概念这一块始终有点弄不清楚。