我正在尝试创建一个程序,该程序对文件中的所有整数进行计数,并检查它们是否为偶数。而且,我不断收到与“检查它们是否均匀”部分相关的错误。这是我的代码:
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<ctime>
#include <string>
using namespace std;
bool isNotEven(int&);
int main()
{
ifstream myfile("input.txt");
int numberTot = 0;
int numberOdd = 0;
int check = 1;
string line;
while(check != -1)
{
getline(myfile,line);
check = stoi(line);
if (check != -1)
numberTot++;
if (isNotEven(check) == true)
numberOdd++;
}
cout << "There are " << numberTot << " numbers in this file." << endl;
cout << "There are " << numberOdd << " odd numbers in this file." << endl;
char x;
cin >> x;
}
bool isNoteEven(int& x)
{
if (x%2 == 0)
return false;
else
return true;
}
我不断收到此错误,并且对为什么出现它感到困惑
1> Lab4.cpp
1>Lab4.obj : error LNK2019: unresolved external symbol "bool __cdecl isNotEven(int &)" (?isNotEven@@YA_NAAH@Z) referenced in function _main
1>C:\Users\Nick\Desktop\CS1\Lab4\Debug\Lab4.exe : fatal error LNK1120: 1 unresolved externals
您不正确地拼写了函数名称isNoteEven而不是isNotEven。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句