gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 11:12:44 25 4
gpt4 key购买 nike

我不明白为什么我的代码无法编译。我看到另一篇文章也有同样的问题,但是他们的问题不是使用#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

关于c++ - Visual Studio编译错误查找文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28866449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com