C++一些问题~~希望高手来看看帮忙解答~~谢谢!!
#include<iostream>#include<cstring>#include<string>usingnamespacestd;intmain(){intcou...
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main()
{
int count=0;
string word;
cout<<"Enter words (to stop,type the word done):"<<endl;
getline(cin,word);
for(int i=1;strcmp("done",word);i++)
{
++count;
getline(cin,word);
}
cout<<"Tiy ebtered a titak of "<<count-1<<"words."<<endl;
system("pause");
}
这道题要求要用string和strcmp()函数来实现这个done之前的计数功能~~但是我打了之后~~里面strcmp("done",word)里面的word老是显示不对~~希望各位高手有实现过才来回答~~~不要猜来猜去!!谢谢!! 展开
#include<cstring>
#include<string>
using namespace std;
int main()
{
int count=0;
string word;
cout<<"Enter words (to stop,type the word done):"<<endl;
getline(cin,word);
for(int i=1;strcmp("done",word);i++)
{
++count;
getline(cin,word);
}
cout<<"Tiy ebtered a titak of "<<count-1<<"words."<<endl;
system("pause");
}
这道题要求要用string和strcmp()函数来实现这个done之前的计数功能~~但是我打了之后~~里面strcmp("done",word)里面的word老是显示不对~~希望各位高手有实现过才来回答~~~不要猜来猜去!!谢谢!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询