我试图编写一个代码来从txt文件中读取文件(尚未完成)。但代码在 .ignore 函数中显示错误。错误:此声明没有存储类或类型说明符
有人可以帮助我这里出了什么问题吗?以下是我的代码。
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
//ifstream inFile;
//ofstream outfile;
//inFile.open("\.\Assignment01", ios::in);
//inFile.ignore(500, '\n');
ifstream input_file;
ifstream input_file("Course_of_sales.txt");
input_file.ignore(500, '\n');
ofstream output_file("output.txt");
string Record;
string day, month, year, hr, mins, secs, PM_AM, condetion;
double price , value;
int volume;
while (getline(inFile, record, ',')){
day = record.substr(0,2);
month = record.substr(3,2);
year = record.substr(6,4);
}
最佳答案
需要将代码放入函数中。感谢尼尔。
关于C++ .ignore 给出错误 "This declaration has no storage class or type specifier",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32709058/