Thread: casting

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    9

    Question casting

    hi there good people,
    i would like to ask a simple question :>)

    spouze you have this:

    int number = 1;
    TCHAR something[10];

    and i would like to know how do i cast:

    something = number;

    so...

    cout<<something;

    would produce:

    1

    it's seems simple enough, i just don't know the language that well,
    thankx in advance for your kind time.
    1976

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    the easiest way is sprintf();

    sprintf(something,"%d",number);

    now something contains (the now character value) 1

  3. #3
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    you can also do

    itoa(number,string,10);

    the 10 means the base you want to convert it to, for example a value of 16 would give an hexagesimal value into the string, this value can go up to 36

    Oskilian

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Casting
    By morvick in forum C++ Programming
    Replies: 2
    Last Post: 06-17-2007, 11:06 PM
  2. Casting Question (I think)
    By fayte in forum C Programming
    Replies: 6
    Last Post: 03-08-2006, 05:31 PM
  3. casting the system exstracted date into seperate ints
    By bazzano in forum C Programming
    Replies: 1
    Last Post: 08-30-2005, 12:17 AM
  4. Type casting
    By Lionmane in forum C Programming
    Replies: 28
    Last Post: 08-20-2005, 02:16 PM
  5. question about casting pointers/other types also??
    By newbie02 in forum C++ Programming
    Replies: 3
    Last Post: 08-07-2003, 05:01 AM