CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2000
    Location
    England
    Posts
    574

    Only a quick question ...

    Hi,
    I realise this is probably the wrong area but
    I need to find out the HEX Value for a character and pass this into a int
    i know im being stupid but for the life of me i can't think how to do this

    Any ideas ?

    ie -

    int nNum = 0
    char ch = "A" // which should be 10
    nNum = ch

    please help !

    Thank again

    P

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641
    int nNum = 0;
    char ch = 'A';
    nNum = (int)ch;

    / Z

  3. #3
    Join Date
    May 2000
    Location
    England
    Posts
    574
    Sorry maybe i didnt make myself clear.

    the value i want placed in the int is the Hexadecimal value of the char

    ie char c = 'A' // which is 10
    but what i get returned into my int is the value of 65 ?

    any ideas what im doing wrong ?

    P

  4. #4
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899
    const char* a = "A";

    int zahl;
    sscanf(a, "%x", &zahl);

    is that what you mean?
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  5. #5
    Join Date
    May 2000
    Location
    England
    Posts
    574
    Yep, Thats great !

    Thanks to both of you ...

    P

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

Featured