我试图测试我们老师给我们的这个宏,并且出于某种原因 我一直收到错误消息。有谁知道为什么?我似乎无法做到 搞清楚。
#include <iostream>
#include <string>
#define die(errmsg) {cerr << errmsg << endl; exit(1);}
using namespace std;
int main()
{
int x;
for(;;)
{
cout <<"How are you: " <endl;
cout <<"1) good\n";
cout <<"2) bad\n";
cin >> x;
if(x != 1 || x != 2)
die("Invalid input");
}
return(0);
}
答案 0 :(得分:4)
cout <<"How are you: " <endl;
您在第二个<
<<
答案 1 :(得分:0)
检查此循环:
for(;;)
{
cout << "How are you: " < endl;
}
您在<
std::endl
for(;;)
{
cout << "How are you: " << endl;
}