0
The problem here is that it creates the file 'test.txt' however when it comes to recording the file it does nothing... I’ve seen the file permission and this ok... I didn’t understand anyone could help me?
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
int numero;
string name;
ofstream outFile;
outFile.open("c:\\x\\test.txt");
if (! outFile)
{
cout << "erro test.txt" << endl;
abort();
}
cout << "Name: \n"
<< "Fim de arquivo (Ctrl-Z) termina a entrada de dados\n\n? ";
while(cin >> numero >> name){
outFile << numero << " " << name<< '\n'; // << Chega aqui ele não faz nada
cout << "? ";
}
outFile.close();
return 0;
}
No Cout tries so || outfile << (number) << " << (name)<< " n"; ||
– jsantos1991
Probably the OS is not flush to the file. Swap
'\n'
forendl
and make sure it resolves.– Vinícius Gobbo A. de Oliveira
of ero when I try (outfile << (number) << " << (name)<< " n";)
– Geovani Luiz
edit the question and post the error
– jsantos1991