public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ajay Bansal" <Ajay_Bansal@infosys.com>
To: "Michal Liptak" <liptak@isdd.sk>, <gcc-help@gcc.gnu.org>
Subject: RE: A simple question of fstream
Date: Thu, 30 Jan 2003 10:31:00 -0000	[thread overview]
Message-ID: <2B721C6525F0D411B1E900B0D0226BDD02148CCD@mohmsg01.ad.infosys.com> (raw)

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.. :( :(

             reply	other threads:[~2003-01-30 10:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-30 10:31 Ajay Bansal [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-01-30 13:00 Ajay Bansal
2003-01-30 10:15 Ajay Bansal
2003-01-30 10:23 ` Michal Liptak
2003-01-30 12:53 ` John Love-Jensen
2003-01-30 13:03 ` John Love-Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2B721C6525F0D411B1E900B0D0226BDD02148CCD@mohmsg01.ad.infosys.com \
    --to=ajay_bansal@infosys.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=liptak@isdd.sk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).