Results 1 to 4 of 4

Thread: hex conversion problem !

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    166

    hex conversion problem !

    hello !

    how can i convert an integer from decimal to hex format in VC++?
    any function available ?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    use itoa and use 16 in the last parameter.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    A standard way:
    [code]
    char *tohex(int i, char *s){
    sprintf(s,"%x",i);
    return s;
    }
    [code]

  4. #4
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    And in C++:
    Code:
    #include <sstream>
    #include <iomanip>
    #include <string>
    
    std::string to_hex(unsigned int n)
    {
        std::stringstream temp;
        temp << std::hex << n;
        return temp.str();
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width