J
james545
I am having a problem with ofstream creating files. Sometimes when I
run the program, ofstream creates a new file for writing and writes to
it. No problem. But sometimes it fails to create the files
altogether. Why doesn't it create files consistently?
(My disk isn't full, and the file didn't previously exist)
Thanks for your help.
sample code:
------------------
ofstream outfile;
outfile.open(fileName, ios:ut | ios::trunc);
if (outfile){
outfile << "my text" << endl;
}
else{
printf("failed to open\n");//for some reason it fails to create a
file sometimes.
}
outfile.close();
------------------
run the program, ofstream creates a new file for writing and writes to
it. No problem. But sometimes it fails to create the files
altogether. Why doesn't it create files consistently?
(My disk isn't full, and the file didn't previously exist)
Thanks for your help.
sample code:
------------------
ofstream outfile;
outfile.open(fileName, ios:ut | ios::trunc);
if (outfile){
outfile << "my text" << endl;
}
else{
printf("failed to open\n");//for some reason it fails to create a
file sometimes.
}
outfile.close();
------------------