View Full Version : c++
aimenkawaz
09-27-2002, 05:56 PM
Hi
i want to make a small program that read and write to a file, so i want to know the commands that used to read and write to a file.
with many thanks
#include <iostream.h>
#include <fstream.h>
int main() {
ifstream myInput("somefile.txt");
char inp;
while (myInput >> inp) {
cout << inp;
}
return 0;
}
For example. ifstream objects also have a few other methods, such as readline().
Writing to a file is easy:
ofstream output("myoutput.txt");
output << "hello world!";
writes "hello world!" to myoutput.txt
aimenkawaz
09-27-2002, 10:14 PM
thank you very much :)
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.