vendredi 24 mars 2023

Detecting end of input with cin.peek()

I am trying to do extraction operator overload that looks at each digit input from user and stores them into an array. Currently, the while loop I am using is not detecting the end of the input stream and the program is just continuously running.

I have tried running a while loop with the logic:

while (cin.peek() != EOF || cin.peek() == '\n') { ... //read in user input }

The input is coming from the terminal not a file.

Aucun commentaire:

Enregistrer un commentaire