Results 1 to 2 of 2

Thread: appeneding another value into a parameter

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    appeneding another value into a parameter

    im trying to put a varible into a parameter with a char * varible as well.

    Code:
    int i(5);
    MessageBox(ghwnd_Main,(LPCSTR)sprintf("Hey this is my number %a",(LPCSTR)i),"",MB_OK);
    it compiles with these warnings

    c:\C++\winControls\winControls.cpp(51): warning C4312: 'type cast' : conversion from 'int' to 'LPCSTR' of greater size
    c:\C++\winControls\winControls.cpp(51): warning C4312: 'type cast' : conversion from 'int' to 'LPCSTR' of greater size
    but at run time it gives me this.

    Unhandled exception at 0x0041ffe6 in winControls.exe: 0xC0000005: Access violation reading location 0x00000005.
    cheers

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Code:
    char msg[120];
    sprintf(msg,"Hey this is my number %d",i);
    MessageBox(ghwnd_Main,msg,"",MB_OK);

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