| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: c++ help |
From: "Geo"
"John Beckett" wrote
in message news:41b2a4bc.23977267{at}216.144.1.254...
> OMG! Please read this slowly -- a lot of details!
Ok first a quick explanation, We haven't been shown itoa function and the
book has minimal information about it (like that it exists and here is the
format with no explanation) so I was just guessing on how to use it.
Here is what I came up with:
void CLottoDlg::OnPlay3()
{
char s[10], a[2], b[2], c[2];
srand(time(NULL));
for (int i=1; i<=rand(); i++)
{
itoa((rand()%10),a,10);
itoa((rand()%10),b,10);
itoa((rand()%10),c,10);
s[0]=a[0];
s[1]='-';
s[2]=b[0];
s[3]='-';
s[4]=c[0];
s[5]='\0';
m_pick3=s;
}
UpdateData(FALSE);
}
this builds the string 4-2-7 or whatever the random function picks for the
3 digits, it does it in a way that at least "appears" to be
pretty random (that's why I use the i<=rand() in the loop) and it's
displaying it correctly in the window of my gui program.
It may not be elegant code, but the trick is not to make the code look
good, the trick is to pick the correct 3 numbers for the lottery.
Ok, on to pick4 :) I'll post a version of the exe when I'm done.
Geo. * Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 396/45 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.