Startpage >> Main >> ReadInfoFromAFile

Read Info From A File

Just redirect information input using ifstream.

For example,

....
ifstream file1("first.txt");
file1>>u[];
....
ifstream file2("second.txt");
file2>>w[];
.....

file1 and file2 denote the stream the info will follow. The names first.txt and second.txt are the names of the files where the information is stored.

We could read info block wise like in here, (file1>>u[]) or use a loop to read each line of data.

return to Matrices and Arrays

Page last modified on April 03, 2014, at 01:00 PM