0

So, as follows I have a basic while loop. It's working fine, however whenever I enter something other than a number or EoF, it goes through the loop one time after I'm wanting it to stop. Say I enter 5, then EoF, it enters an extra 5, so I have two entries of fives.

while(std::cin){
    std::cin >> numberinput;
    LinkedList.InsertFront(numberinput);
  }

Almost positive I'm overlooking something simple, but all help is appreciated

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by subith86
0

try this :)

while(std::cin >> numberinput){
    //std::cin >> numberinput;
    LinkedList.InsertFront(numberinput);
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.