Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-13-2003, 02:30 PM   #1
Registered: Jun 2003
Location: Calcutta, India
Distribution: Slackware 9.0
Posts: 34

Rep: Reputation: 15
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;"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!
Old 09-13-2003, 02:40 PM   #2
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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)

Last edited by kev82; 09-13-2003 at 02:41 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Module Programming...file not included b_mallerd Programming 2 10-17-2005 01:56 PM
How to call a saved file using Gtk programming m.harshavardhan Linux - Software 2 08-20-2005 08:10 AM
Kernel Programming help needed arunka Linux - General 1 03-01-2005 06:53 AM
Unix socket programming - how to sent a file Scrag Programming 9 03-28-2004 10:54 PM
PCI programming help needed sarin Programming 2 09-01-2002 05:52 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration