can't write on a txt!

Hello,in my program i have to write some points on a txt file,so what i'm doing is:
1
2
3
4
5
6
7
8
9
ofstream fileoutput("file.txt",std::ios::out | std::ios::app);
//find points
findMean(points,fileoutput);

void findMean(vector<int>points,ofstream &fileoutput){
//find mean of points and then..
fileoutput<<mean<<endl;
fileoutput.close();
}


the code compile and works,i mean if i do a cout of mean before putting in file values are correct,but when i close the program file.txt is empty.what can be the problem?

ok i added an if(!fileoutput) with a cout and it prints,so cannot find the file.what can i do?
if i do:
1
2
fstream fileoutput;
fileoutput.open("file.txt", std::ios::out | std::ios::app)

or
1
2
fstream fileoutput;
fileoutput.open("file.txt",fstream::out | fstream::app)


kdevelop gives an error on that .open so if i compile get error.but i included iostream and fstream,so i'm lost on this..
Last edited on
Topic archived. No new replies allowed.