Thread: figuring out size of numbers

  1. #16

  2. #17
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    I've used atoi() in my code already, so I will use itoa() to go the other way. and the format function won't help. The variable has to be a const char* to be used in one of the functions, so I have to convert it. Casting it gives a run-time read error.

    thanks,

    AS
    Everything is relative...

  3. #18
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Maybe I'm missing something, but why don't you just read the user's input as an integer?
    Code:
    cout << "Enter a four digit number immediately: ";
    int entry;
    (cin >> entry).get();
    if (!is_four_digits(entry))
      cout << "Yo stupid, I said enter a fo' digit numbah son!" << endl;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  3. char problem
    By eXistenZ in forum Windows Programming
    Replies: 36
    Last Post: 02-21-2005, 06:32 AM
  4. Replies: 11
    Last Post: 03-25-2003, 05:13 PM
  5. programming with random numbers
    By xstudent in forum C Programming
    Replies: 13
    Last Post: 05-21-2002, 01:36 AM