How can I read a matrix with getline from a file. Please see example. What is the best way to read this from file?thanks | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I read a matrix with getline from a file. Please see example. What is the best way to read this from file?thanks

2 3 000 000 000

6th Feb 2019, 10:45 PM
Olga Mohan
Olga Mohan - avatar
2 Answers
0
do you have to use getline()?? if not maybe consider... Use ifstream to read data from a file: std::ifstream input( "filename.ext" ); If you really need to read line by line, then do this: for( std::string line; getline( input, line ); ) { ...for each line in input blah blah lol }
7th Feb 2019, 1:28 AM
peter
peter - avatar
0
Thank for your answer, do you think that with simple ifstream reading should be ok? Because the first two lines are different, and I am thinking that ,this might cause a problem
7th Feb 2019, 5:48 AM
Olga Mohan
Olga Mohan - avatar