Xuất nhập tệp trong C++

Viết trên IDE thì chạy được nhưng trên web test case lại in ra số dòng trong tệp làm output sai .sửa ntn ạ

#include<iostream
#include<fstream
using namespace std;
void nhaptep(const char* path)
      ifstream File(path);
    if(!File){
        cout<<"Error!";
    }
        while(!File.eof()){
            string line;
            getline(File,line);
            if(File){
            cout<<line<<endl;
            }
        }
        File.close();
}

Chạy được là thế nào nhỉ. Có in ra đúng như yêu cầu không. :smiley:

4 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?