C++ : File I/O Part 1

1. Explain the use of File I/O.

2. Header file for the File I/O operation in C++ fstream.

3. Inbuilt class for File I/O operation in C++:

1. ofstream.

2. ifstream.

3. fstream.

4. Read and Write Integer and String value into the File.

5. Example showing the use of reading & writing data into the File.


/*
Developed By: Prof. Vinod Pillai
vinodthebest@gmail.com
C++ File I/O - Part 1.
*/

#include
#include

using namespace std;

int main()
{

ofstream fout("one.txt");
int val1,rel1;
char val2[20],rel2[20];

cout<>val1;
cout<>val2;

fout<<val1;
fout<>rel1;
fin>>rel2;

cout<<"\n Integer value 1:"<<rel1;
cout<<"\n String value 2:"<<rel2;

return 0;
}

Advertisements

1 Comment

Filed under C++, File I/O

One response to “C++ : File I/O Part 1

  1. Thanks very nice blog!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s