This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: A simple question of fstream


I also figured one sol...

If I use 
iostrm.open("new1.txt",ios::out | ios::in | ios::trunc);

File is created. I just want to know the logic behind this


-----Original Message-----
From: Michal Liptak [mailto:liptak@isdd.sk] 
Sent: Thursday, January 30, 2003 3:57 PM
To: gcc-help@gcc.gnu.org
Subject: Re: A simple question of fstream


try this..

int main(void) {
ofstream of;
of.open("name");
if (of.fail()) return -1;
of<<"text";
of.close();
return 0;
}

m.

On Thu, 30 Jan 2003 14:01:12 +0530
"Ajay Bansal" <Ajay_Bansal@infosys.com> wrote:

>Hi All
>
>I want from the following program to create a new file & write into it.

>But it is not doing so. I am compiling with gcc 3.2.1
>
>#include <fstream>
>#include <iostream>
>#include <stdlib.h>
>#include <errno.h>
>using namespace std;
>
>int main()
>{
>fstream iostrm;
>
>iostrm.open("new1.txt",ios::out | ios::in);
>
>cout<<errno;
>iostrm.write("gagan",5);
>
>iostrm.close();
>
>return 1;
>
>}
>
>What is wrong over here. If I compile the program using gcc 2.95, I get

>a new file.
>
>-Ajay
>
>
>PS: about my prior mails on compatibility issues with 2.95 & 3.2.1... I

>am changing my code to meet with the standards.. :( :(


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]