常见的条件是(cin>>a)
而(cin)是什么意思?
c++primer5thP170 ex5.18中(a)(是do while的改错)
do
int v1,v2;
cout << "Please enter two numbers to sum:";
if (cin >> v1 >> v2)
cout <<"Sum is: " << v1 + v2 << endl;
while (cin)
又如在ex5.20中 自己写的main如下
int main()
{
string temword;
string textword;
while (cin >> textword){
if (textword == temword)
break;
temword = textword;
}
if (cin)
cout << temword << endl;
else
cout << "Empty!" << endl;
return 0;
}
其中if(cin)是瞎试出来的 的确不懂意思
求解答 先睡觉了
而(cin)是什么意思?
c++primer5thP170 ex5.18中(a)(是do while的改错)
do
int v1,v2;
cout << "Please enter two numbers to sum:";
if (cin >> v1 >> v2)
cout <<"Sum is: " << v1 + v2 << endl;
while (cin)
又如在ex5.20中 自己写的main如下
int main()
{
string temword;
string textword;
while (cin >> textword){
if (textword == temword)
break;
temword = textword;
}
if (cin)
cout << temword << endl;
else
cout << "Empty!" << endl;
return 0;
}
其中if(cin)是瞎试出来的 的确不懂意思
求解答 先睡觉了
