0

I try to get inputs via text file. I can take the all inputs in the text file but while loop didn't stop. It takes over and over. Here is the code block;

ifstream inFile;    

    inFile.open("infixData.txt", std::fstream::in | std::fstream::out | std::fstream::app);

    if(inFile.is_open()){
         while (!inFile.eof()){
        getline(inFile, inputInfix);
        getInfix(inputInfix);
        showInfix();
        }

    }
    inFile.close();  

I didn't understand why eof() function dont stop the loop. I tried with it bad() function too, It gets worse.

Levent Kaya
  • 31
  • 1
  • 3
  • 1
    "It gets worse" - in what way does it get worse? Please describe any behaviors, error messages, etc that you see – nanofarad Apr 23 '20 at 16:01
  • 4
    Does this answer your question? [Why is iostream::eof inside a loop condition (i.e. \`while (!stream.eof())\`) considered wrong?](https://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-i-e-while-stream-eof-cons) – Adrian Mole Apr 23 '20 at 16:03

0 Answers0