Monday, May 17, 2010

1) what include file do I need?
2) what data types are available
3) how do i declare?
4) how do i use

1)
#include // for cin and cout
#include // for file io

2)
ifstream
ofstream

these are data types, just like int, double, string

3)
ifstream jin;
ofstream jout;

alternatively:
ifstream jin("hello.txt");
ofstream jout("myoutput.txt");

4)
open a file:
jin.open("hello.txt");
jout.open("myoutput.txt");

close a file:
jin.close();
jout.close();

read from a file:
int x;
jin >> x;

write to a file:
jout << x << "hello" << endl;

No comments:

Post a Comment