gpt4 book ai didi

C++ .ignore 给出错误 "This declaration has no storage class or type specifier"

转载 作者:行者123 更新时间:2023-11-30 17:10:49 24 4
gpt4 key购买 nike

我试图编写一个代码来从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/

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