0

ok so i wanted to make a number randomiser like so:

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    srand((unsigned)time(0)); 
    int random_integer; 
    for(int index=0; index<20; index++){        
        random_integer = (rand()%60)+1; 
        MessageBox(NULL, "Random Number: ", "Bingo",MB_OK | MB_ICONINFORMATION);

        Sleep(2000);
    } 

return 0;

}

I want to put the randon_integer result into the message box in front of  "Random Number: "

can anyone help me on this ? thanks
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by slim2hott
0

Write it to a string with sprintf (or wsprintf):

sprintf( buf, "Random Number: %d", random_integer );
MessageBox( 0, buf, ... )
0

Write it to a string with sprintf (or wsprintf):

sprintf( buf, "Random Number: %d", random_integer );
MessageBox( 0, buf, ... )

ok thanks :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.