figuring out size of numbers

This is a discussion on figuring out size of numbers within the C++ Programming forums, part of the General Programming Boards category; stringstream...

  1. #16
    Banned
    Join Date
    Jun 2005
    Posts
    594

  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;

Page 2 of 2 FirstFirst 12
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, 02:30 PM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 10: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, 02:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21