Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,578 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,967 people online right now. Registration is fast and FREE... Join Now!




error checking!

 
Reply to this topicStart new topic

error checking!, how to test if a character is a float/double?

Pad0
26 Sep, 2008 - 03:14 PM
Post #1

New D.I.C Head
*

Joined: 10 Jun, 2008
Posts: 23

I have a program that will allow the user to perform different actions on a polynomial. One of the actions is multiply. How can I make sure the user is entering a number as a multiplier? If it was an int, i could use isnum(x), but my professor wants us to allow the user to enter a float or double.

CODE

  cout << "Enter mulitplier: ";
  cin >> x;
  while(isalpha(x) || isspace(x))
  {
    cout << endl;
    cout << "You must enter a number!" << endl;
    cout << "Enter multiplier: ";
    cin >> x;
  }



Thanks,
pad0
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 12:21AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month