0

How to store an array of numbers from a text file in Cpp?

I'm trying to have the user to enter the name of the file they wish to open, then the contents of the file will be displayed.

11th Feb 2019, 9:15 PM
Anfernee Skinner
Anfernee Skinner - avatar
1 Réponse
0
break it into simpler stages that get the results. like... open the file start a loop read a line maybe ifstream getline() exit this loop if end-of-file reached no reading if all read process the line store tokens in the array go back to start of loop end of loop break out with a result. lol sounds nuts, easier to code be something simular to ifstream infile("myfile.txt"); std::string line; if( infile.is_open() ) { while( getline(infile,line) ) { // do something here } } play with codes it will come to you
11th Feb 2019, 11:47 PM
peter
peter - avatar