LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   c++ file i/o programming help needed (https://www.linuxquestions.org/questions/linux-newbie-8/c-file-i-o-programming-help-needed-92423/)

rajorshi 09-13-2003 01:30 PM

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!

kev82 09-13-2003 01:40 PM

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.