How works while ( getline (MyFile, line) ) { cout << line << '\n'; } ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

How works while ( getline (MyFile, line) ) { cout << line << '\n'; } ?

We take line from file MyFile, enter it to line, and then move the cursor to next line. In while in this iteration is address (what is the address?). We output line, and all starts again, and so while in while getline doesn't give 0. And getline give 0, when in line MyLine, where is the cursor, will not give empty. Is everything correct?

13th Aug 2017, 2:20 PM
Alexik - avatar
1 Answer
Have you declare a variable? (I’m new like all I know is how to print words and address a variables so take this with a grain of salt plz) hopefully someone who knows more can help. Well any way we established the variable issue Like “int MyFile = line; ” this may not work on the off chance it does then cool but I don’t expect it to. Or try To declare line as int and make Line capital. Int Line = MyFile;
19th Jan 2018, 8:21 PM
msr47 gaming
msr47 gaming - avatar