Hai friends, I'm stuck with a input validation where if nothing is entered and enter is pressed, then i need to display a message saying please enter some value.
alekhya
0
Newbie Poster
Recommended Answers
Jump to Postdepends on whether its a string or numeric value. If you code it to always enter data as strings then you can easily test for empty string, then convert the string to some numeric value if needed.
Jump to Post>>anyways please tell me how to do it....
I thought I already did.std::string input; int value; while(input == "") { cout << "Enter something"; cin >> input; }; // now convert to integer stringstream sstr(input); sstr >> value;
All 6 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
alekhya
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
alekhya
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Daveodolph
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.