c++ - Visual Studio编译错误查找文件

我不明白为什么我的代码无法编译。我看到另一篇文章也有同样的问题,但是他们的问题不是使用#include,也没有使用命名空间std,这两个我都有。有人知道为什么吗? ps。我的代码还没有完成,但是我想在继续之前使它起作用。

#include <iostream>
#include <string>
#include <fstream>
using namespace std;

//Function prototypes to warn main function
void readData(int num);
void oddTally(int num);
void oddSum(int num);
void oddAverage(double num);
void evenTally(int num);
void evenSum(int num);
void evenAverage(double num);
void displayNames(string name1, string name2);

int main()
{
int inData, oTally, oSum, eTally, eSum;
double oAverage, eAverage;
string name1, name2;

ifstream inFile;
readData(inData);
oddTally(oTally);
oddSum(oSum);
oddAverage(oAverage);
evenTally(eTally);
evenSum(eSum);
evenAverage(eAverage);

system("pause");
return 0;
}
void readData(int num)
{
ifstream inFile;
inFile.open("in.txt");
int inData;

//Read the data.
if (inFile)
{
    while (inFile >> inData)
    {
        cout << inData << '\n';
    }
}
else
{
    //Displays error message.
    cout << "Error opening the file. \n";
}
}

最佳答案

你需要:

#include <cstdlib>

使用system

https://stackoverflow.com/questions/28866449/

相关文章:

java - 如何调用其他类(class)的名单?

java - 错误 : variable data might not have been init

java - vlcj 在尝试创建服务器流时出错

java - 为什么我无法定义数组?

c++ - 错误 : too many template-parameter-lists

c# - 并非所有代码路径都返回值: Unity

c++ - ISO C++禁止声明多集

java - Unresolved 编译问题: The method parseInt(String

sql-server - 从以下脚本获取错误

java - Java博士;为什么不编译呢?