c++ file i/o programming help needed
Hi all,
I'm new to standard C++. I seem to have a problem: Whenever I create a file in Linux (gcc 3.2.2) as follows: fstream f; f.open("somefile.dat",ios::app|ios::in|ios::ate); the file does not get created (f remains null). However if I use 'touch' to create the file beforehand, it succeeds. The code above was found in two textbooks I am referring to. Am I doing something obviously wrong ? I use Slack 9.0 and was coding in a non-root account. Please help! |
your passing the flag ios::in therefore you are opening the file for reading, what would be the point of creating the file because it would be empty. use ios::out if you want to output to the file(creating it if not already present)
|
All times are GMT -5. The time now is 04:57 PM. |