ofstream problem
I wrote this code on Linux RedHat9
... #include <fstream> ... ifstream file(myfile); //and all was OK, I was able to read it //bur when I wrote ... ofstream file(myfile, ios::app); if (!file) cout << "File" << myfile << "could no be opened" << endl; return 1; else ... //the program ended with the message above. The name of the myfile was the same and the location too. Could somebody help. Thank zou very much. |
do you have permissions to write to the file?
your first example std::ifstream infile( some_file ) is essentially the same as: std::ifstream infile( some_file, std::ios::in ); // read only but your second: // append or random access std::ofstream outfile( some_file, std::ios::app ) Verbal |
Thank you very much. I set permission to other and all is OK. I thought that when I logged in as a root and had permission to the file for writting, it was enough.
|
All times are GMT -5. The time now is 08:23 PM. |