好的,所以我环顾四周,但我仍然不太明白为什么会收到此错误。我的代码包含在下面。我有一些运行良好的旧代码。然后我决定让它在每次打开应用程序时执行多个计算。在修复了其他几个错误后,弹出了这个错误。在我意识到我需要 ' ' 围绕 y 之后,这个突然出现了。
#include "stdafx.h"
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
int x;
int y;
int result;
char z;
char a = 'y';
char st();
{
cout << ("Do another calculation?: y/n");
cin >> a;
if (a = 'n')
{
system("PAUSE");
return 0;
}
}
while (a = 'y');
{
cout << "Symbol here: " <<endl;
cin >> z;
cout << "Number 1: " <<endl;
cin >> y;
cout << "Number 2: " <<endl;
cin >> x;
if (z == '*')
{
result = x * y;
cout << "Answer:" << result <<endl;
st();
}
else if (z == '/')
{
result = x * y;
cout << "Answer:" << result <<endl;
st();
}
else if (z == '-')
{
result = x / y;
cout << "Answer:" << result <<endl;
st();
}
else if (z == '+')
{
result = x + y;
cout << "Answer:" << result <<endl;
st();
}
else if (z == '%')
{
result = y % x;
cout << "Answer:" << result <<endl;
st();
}
}
}