Im accepting a float from the user. I want to protect from him inputing a char cos it messes everything up. How do i do this?
sroberts82
0
Newbie Poster
Recommended Answers
Jump to Postdo u mean numercal value ?only not charcters ??
Jump to Postbtw ..Here is a simpler program that throws away the error characters:
#include <iostream> using namespace std; int main() { int x = 0; do { cout << "Enter a number (-1 = quit): "; if(!(cin >> x)) { cout << "Please enter numeric characters only." << …
All 6 Replies
meabed
37
Junior Poster
Team Colleague
meabed
37
Junior Poster
Team Colleague
sroberts82
0
Newbie Poster
meabed
37
Junior Poster
Team Colleague
sroberts82
0
Newbie Poster
Dave Sinkula
2,398
long time no c
Team Colleague
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.