"Adding" to a int?

This is a discussion on "Adding" to a int? within the C Programming forums, part of the General Programming Boards category; is it possible to add a character and not a number to a int? so something like x = 1 ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    913

    "Adding" to a int?

    is it possible to add a character and not a number to a int? so something like x = 1 and a 1 would give me 11 and not 2.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Yes:
    Code:
    int AddDigitToNumber(int Number, int Digit)
    {
       return ((Number * 10) + Digit);
    }
    Assuming Digit is in the range 0 - 9.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  2. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  3. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 06:20 AM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  5. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 07:34 AM

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