This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
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..
>:( :(