Using the C++ Math Library    

Using Stream I/O to Files 

The preceding example demonstrates stream input from and output to the terminal. To read or write arrays from and to files, use the C++ class ifstream to create file input streams and ofstream to create file output streams.

For example, the code fragment shown below writes array A to a file and then reads the data from the file into array B.

Note that in order to run the code fragment, you need to insert the following at the top of the program:

The code fragment is as follows:

A and B are now equal.


 Stream I/O Format Definitions Using Streams for Interprocess Communication