O arquivo não está abrindo, mesmo que exista [fechado]
No programa a seguir, ele grava dados com êxito emstudent.txt
arquivo, mas quando eu o abro e imprimo linha por linha do arquivo, ele sempre mostra o arquivo não encontrado.
Alguém poderia me ajudar com isso?
ifstream Myfile;
Myfile.open("student.txt");
if(!Myfile){
cout<<"Sorry file can't be opened" <<endl;
exit(1);
}
else
{
// Use loop and read the names and ids from the file and display them
string line;
while (getline(Myfile, line)){
cout<<line<<endl;
}
// Close the file
Myfile.close();