Results 1 to 3 of 3

Thread: Data types conversions

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    50
    How can i convert from (for example) long to char ?
    For example: i use api, which returned long value. How can i this value view in MessageBox function ?

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    To convert the long value to char and display it in
    a message box use this code:
    Code:
    long l = 250; 
    char *c = new char;
    MessageBox(hWnd,itoa(l,c,10),"Caption",MB_OK);
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You need to have a proper buffer to avoid possible problems:
    Code:
    long l = 250;
    char c[30];
    MessageBox(hWnd,ltoa(l,c,10),"Caption",MB_OK);
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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