Thread: Help!!!!!!!!!!!!

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    30

    Angry Help!!!!!!!!!!!!

    i want msgbox to show numbers

    but for some reason it's not work i tried cast but it's not work

    someone can plz help me?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    A quick way;

    Code:
    int x = 10;
    char buff[3];
    
    
    sprintf(buff,"%s",x);
    MessageBox(0,buff,"And the number is:",MB_OK);

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    30
    it's not work


    and what's sprintf() and wsprintf()?

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Doh!!! slight ballsup

    should be;

    Code:
    int x = 10;
    char buff[3];
    
    
    sprintf(buff,"%i",x);
    MessageBox(0,buff,"And the number is:",MB_OK);
    sprintf and wsprintf are an easy way to put an integer into a string (MessageBox will only take a string buffer).

    You need the header stdio.h

  5. #5
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    try this:
    Code:
    #include <stdio.h>
    #include <windows.h>
    
    int main(void)
    {
        int x = 10;
        char buff[3];
    
        sprintf(buff,"%i",x);
        MessageBox(0,buff,"And the number is:",MB_OK);
        return 0;
    }
    sprintf puts a value/string/whatever into a buffer.

    edit 1:

    Damn you for fixing it before me! We must've posted at the same exact time.

Popular pages Recent additions subscribe to a feed