How to put a int name into a messagebox

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2009
Posts: 20
Reputation: slim2hott can only hope to improve 
Solved Threads: 0
slim2hott slim2hott is offline Offline
Newbie Poster

How to put a int name into a messagebox

 
0
  #1
Apr 24th, 2009
ok so i wanted to make a number randomiser like so:

  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. srand((unsigned)time(0));
  9. int random_integer;
  10. for(int index=0; index<20; index++){
  11. random_integer = (rand()%60)+1;
  12. MessageBox(NULL, "Random Number: ", "Bingo",MB_OK | MB_ICONINFORMATION);
  13.  
  14. Sleep(2000);
  15. }
  16.  
  17. return 0;
  18.  
  19. }
  20.  
  21. I want to put the randon_integer result into the message box in front of "Random Number: "
  22.  
  23. can anyone help me on this ? thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 476
Reputation: nucleon has a spectacular aura about nucleon has a spectacular aura about 
Solved Threads: 91
nucleon's Avatar
nucleon nucleon is offline Offline
Posting Pro in Training

Re: How to put a int name into a messagebox

 
0
  #2
Apr 24th, 2009
Write it to a string with sprintf (or wsprintf):
  1. sprintf( buf, "Random Number: %d", random_integer );
  2. MessageBox( 0, buf, ... )
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 20
Reputation: slim2hott can only hope to improve 
Solved Threads: 0
slim2hott slim2hott is offline Offline
Newbie Poster

Re: How to put a int name into a messagebox

 
0
  #3
Apr 24th, 2009
Originally Posted by nucleon View Post
Write it to a string with sprintf (or wsprintf):
  1. sprintf( buf, "Random Number: %d", random_integer );
  2. MessageBox( 0, buf, ... )
ok thanks
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC