Menu

wsprintf

2003-01-04
2012-09-26
  • Derek Baker

    Derek Baker - 2003-01-04

    According to the Win32 Programmers Reference:

    S    A string. This sequence is interpreted as type LPSTR when the calling application uses the #define UNICODE compile flag and as type LPWSTR otherwise.

    However if I change the %s in the code below to %S,

    wsprintf(Buffer, "Save changes to %s", szFileTitle);
                                temp = MessageBox(hwnd, Buffer, TEXT("Text"), MB_YESNOCANCEL | MB_ICONEXCLAMATION);

    I get the output:

    Save changes to ????

    The UNICODE flag is not defined in my program.

    Any ideas why this is so?

    Derek

     
    • Nobody/Anonymous

      Read the reference again -- if UNICODE is not defined then the type is LPWSTR, a wide character string so ordinary character string may appear as sequence of unprintable wide characters.

      tkorrovi

       
    • Derek Baker

      Derek Baker - 2003-01-04

      Thanks tkorrovi, you're right. My mistake.

      Derek

       
      • Nobody/Anonymous

        It's OK it seems that wsprintf cause the conversion with S (whatever it is) but there is no implicit conversion back to ordinary string. Also it's likely that LPSTR is interpreted as wide character string when UNICODE is defined though I never used unicode.

        tkorrovi

         
      • Nobody/Anonymous

        Oh no, now I was wrong, it causes conversion of wide characters to sequence of ordinary characters whatever it means.

        tkorrovi

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.