-
Simple File I/O
It has been forever since I've programmed in C++, and I have sold off all of my programming reference books... I just need help in coding a routing to open a textfile to read 3 lines of 3 numbers, separated by spaces as such:
10 20 30
40 50 60
70 80 90
placing them into a 2d array... I'm having a hard time locating the procedures online as well... If someone could provide me with sample code or a link to an online source for such a task, it would be grateful.
-
Code:
int MyVar;
ifstream ReadFile;
ReadFile.open("MyFile.txt", ios::in | ios::nocreate);
if(!ReadFile.fail())
{
//Reads one integer
ReadFile >> Myvar;
ReadFile.close();
}
-
There are hundreds of samples of file I/O on this board. Search the board with "ifstream".
gg