2015-09-22 2 views
0

Я пытался написать код для чтения файла из txt-файла (его еще не завершено). Но код, показывающий ошибку в функции .ignore. Ошибка: This declaration has no storage class or type specifier может кто-нибудь помочь мне, что здесь не так? Ниже приведен мой код. Я очень новичок в Cpp. Заранее спасибо.C++ .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); 
} 
+0

Вам нужно ввести свой код в функцию. –

+0

Вы не можете выводить утверждения вне функций, только декларации и определения. –

+0

О да. Это сработало. Я только что объявил о своей функции. Большое спасибо друзьям – gentle

ответ

0

необходимо ввести код в функцию. Благодаря Нейлу.

Смежные вопросы