Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

std::cin input being skipped?

$
0
0
Some input is being skipped and it sets the variable to null or empty or something. Here is the relevant code
short int bindedPort;

//prompt for the port
std::cout<<"What port would you like to bind to?"<<std::flush;
std::cin >> bindedPort;
std::cout << std::endl;

 std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );

// Let the server know this client is connected
std::string ID;
std::cout<<"\nEnter an ID: "<<std::flush;
ID = std::cin.get();



The first cin works but the second one is skipped and an empty string is sent to the server. Can someone help me?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>