Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ISDIGIT Function

ISDIGIT Function

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    How do I use the isdigit function my program won't compile. It says invalid operands of types `long double' and `' to binary `operator==' Here is my program //Calculator program #include #include using namespace std; int main () { long double var1; long double var2; char sign; //Begin calculator loop. Will loop continuously until first //number entered is a 0. do { cout << "Enter a number "; cin >> var1; cout << "Enter a sign "; cin >> sign; cout << "Enter a number "; cin >> var2; if(var1 == isdigit) continue; //Begin calculator functions. +, -, /, *. switch (sign){ case ('+'): cout << var1 + var2 << '\n' << '\n'; break; case ('-'): cout << var1 - var2 << '\n' << '\n'; break; case ('*'): cout << var1 * var2 << '\n' << '\n'; break; case ('/'): cout << var1 / var2 << '\n' << '\n'; break; default: cout << "You didn't enter a correct sign"; cout << '\n' << '\n'; break; //If the user enters an unrecognized sign they will get a //message that says: You ddn't enter a correct sign. } } while (var1 != 0); //If first number entered is a 0 //the program will terminate at the end //of the loop. (The Do While loop) } :confused:

    S 1 Reply Last reply
    0
    • L Lost User

      How do I use the isdigit function my program won't compile. It says invalid operands of types `long double' and `' to binary `operator==' Here is my program //Calculator program #include #include using namespace std; int main () { long double var1; long double var2; char sign; //Begin calculator loop. Will loop continuously until first //number entered is a 0. do { cout << "Enter a number "; cin >> var1; cout << "Enter a sign "; cin >> sign; cout << "Enter a number "; cin >> var2; if(var1 == isdigit) continue; //Begin calculator functions. +, -, /, *. switch (sign){ case ('+'): cout << var1 + var2 << '\n' << '\n'; break; case ('-'): cout << var1 - var2 << '\n' << '\n'; break; case ('*'): cout << var1 * var2 << '\n' << '\n'; break; case ('/'): cout << var1 / var2 << '\n' << '\n'; break; default: cout << "You didn't enter a correct sign"; cout << '\n' << '\n'; break; //If the user enters an unrecognized sign they will get a //message that says: You ddn't enter a correct sign. } } while (var1 != 0); //If first number entered is a 0 //the program will terminate at the end //of the loop. (The Do While loop) } :confused:

      S Offline
      S Offline
      SJolly
      wrote on last edited by
      #2

      Try: if(isdigit(var1)) continue; in place of: if(var1 == isdigit) continue; Regards, Simon

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups