Thread: itoa(int, const char*, int)

  1. #1
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859

    itoa(int, const char*, int)

    how do i work this thing?

    i got a access violation

    edit: with the last number, that is...)
    Last edited by Yoshi; 12-13-2002 at 02:47 PM.
    Yoshi

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    int main()
    {
       char Buffer[64];
       int MyVar = 165;
    
       cout << "Look, 165: " << itoa(MyVar, Buffer, 10) << endl;
    
       cout << "Look, 165 in hexadecimal: " << itoa(MyVar, Buffer, 16) << endl;
    
       cout << "Look, 165 in binary: " << itoa(MyVar, Buffer, 2) << endl;
    
       return 0;
    }
    The first argument is the number being converted.
    The second argument is an adress to a buffer (the string got to be stored somewhere).
    The third argument is the radix, the base, of the converted number, ie 2 for binary, 8 for octal, 16 for decimal etc...
    Last edited by Magos; 12-13-2002 at 02:51 PM.
    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.

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    The third argument is the radix, the base, of the converted number, ie 2 for binary, 8 for octal, 16 for decimal etc...
    Or 10 for a normal decimal number

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by face_master
    Or 10 for a normal decimal number
    ya, forgot the most basic one...

    or 3 for ternal
    or 4 for quaternal
    or 5 for quinal
    or 6 for senal
    or 7 for septenal
    or 9 for nonal
    or 11 for undenal
    or 12 for duodecimal
    or 13 for tridecimal
    or 14 for quattuordecimal
    or 15 for quindecimal
    or 17 for septendecimal
    or 18 for octodecimal
    or 19 for nonadecimal
    or 20 for vigesimal
    or 30 for trigesimal
    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. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  2. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  3. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 07:34 AM
  4. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM