954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Basic while loop question

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

butler273
Newbie Poster
10 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

try this :)

while(std::cin >> numberinput){
    //std::cin >> numberinput;
    LinkedList.InsertFront(numberinput);
}
subith86
Junior Poster
124 posts since Mar 2011
Reputation Points: 30
Solved Threads: 14
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You