ostream [modified]
-
hi, i want to use ostream to write to a txt file, though i dont want it to automaticly start a new txt file, if a text file already excists, but behave similar as : FILE* f=fopen("txt.txt","a"); fwrite(buffer,sizeof(buffer),1,f); thanks -- modified at 16:22 Thursday 3rd August, 2006
-
hi, i want to use ostream to write to a txt file, though i dont want it to automaticly start a new txt file, if a text file already excists, but behave similar as : FILE* f=fopen("txt.txt","a"); fwrite(buffer,sizeof(buffer),1,f); thanks -- modified at 16:22 Thursday 3rd August, 2006
FredrickNorge wrote:
FILE* f=fopen("txt.txt","a"); fwrite(buffer,sizeof(buffer),1,f);
That isn't using ostream ... If you want to use ostream (specifically, ofstream):
ofstream fout("file.txt", ios::out | ios::app); fout << "Hello, world!" << endl;
That will open a file named "file.txt" for output and append "Hello, world!" to the end of the file.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
FredrickNorge wrote:
FILE* f=fopen("txt.txt","a"); fwrite(buffer,sizeof(buffer),1,f);
That isn't using ostream ... If you want to use ostream (specifically, ofstream):
ofstream fout("file.txt", ios::out | ios::app); fout << "Hello, world!" << endl;
That will open a file named "file.txt" for output and append "Hello, world!" to the end of the file.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
thanks , perfect!