Results 1 to 5 of 5

Thread: unsigned char to const char *

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    unsigned char to const char *

    I have this code:

    Code:
    int systeminfo()
    {
    SYSTEM_POWER_STATUS sps;
    HDC hdc;
    
    GetSystemPowerStatus(&sps);
    
    hdc = GetDC(hwnd);
    
    TextOut(hdc,5,5,sps.ACLineStatus,3);
    
    ReleaseDC(hwnd,hdc);
    
    	return 0;
    }

    error C2664: 'TextOutA' : cannot convert parameter 4 from 'unsigned char' to 'const char *'
    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    Error executing cl.exe.

    how do i format this to work? Thanks
    and i get the error:
    Matt

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    one way:
    Code:
    int systeminfo()
    {
    SYSTEM_POWER_STATUS sps;
    HDC hdc;
    char tmp[4];
    GetSystemPowerStatus(&sps);
    
    hdc = GetDC(hwnd);
    memset(tmp,0x00,sizeof(tmp));
    tmp[0]=sps.ACLineStatus;
    TextOut(hdc,5,5,tmp,3);
    
    ReleaseDC(hwnd,hdc);
    
    	return 0;
    }

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Why 4 characters long? For alignment?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Yes. - habit from HP unix.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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