Help!!!!!!!!!!!!

This is a discussion on Help!!!!!!!!!!!! within the Windows Programming forums, part of the Platform Specific Boards category; i want msgbox to show numbers but for some reason it's not work i tried cast but it's not work ...

  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,789
    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,789
    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,230
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21