Click here to Skip to main content
16,005,339 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: File Database & Data Structure :: C++ Pin
Paul M Watt24-Feb-02 15:16
mentorPaul M Watt24-Feb-02 15:16 
GeneralRe: File Database & Data Structure :: C++ Pin
valikac24-Feb-02 15:50
valikac24-Feb-02 15:50 
GeneralSearch a string in another string Pin
24-Feb-02 6:44
suss24-Feb-02 6:44 
GeneralRe: strstr, wcsstr Pin
24-Feb-02 7:06
suss24-Feb-02 7:06 
GeneralRe: Search a string in another string Pin
24-Feb-02 12:41
suss24-Feb-02 12:41 
GeneralAAAAAAAAAAAAAAAARGH! Pin
Georg Haan24-Feb-02 5:52
Georg Haan24-Feb-02 5:52 
Generalsrand() Pin
Mazdak24-Feb-02 5:47
Mazdak24-Feb-02 5:47 
GeneralRe: srand() Pin
Georg Haan24-Feb-02 6:18
Georg Haan24-Feb-02 6:18 
srand delivers a number between 0 and <insert very="" large="" int="" here="">

to break it down to a number 1 - 20 you must modulate it.

the operator for that is %

better explained:

4 % 3 = 1

'%3' means as much as 'deduct 3 until I have a number less than 3'

0%3=0
1%3=1
2%3=2
3%3=0
4%3=1
5%3=2
6%3=0
etc.

srand()%20 will give you a number between 0 and 20.
to get a number between 1 and 20 use this:
(srand()%19)+1

BTW, a few months back I saw a CMersenneTwister class here on the codeproject. You might want to take a look at it, it's a better random number generator...

Georg Haan (.NL)
GeneralRe: srand() Pin
Mazdak24-Feb-02 7:16
Mazdak24-Feb-02 7:16 
GeneralRe: srand() Pin
Tim Smith24-Feb-02 7:31
Tim Smith24-Feb-02 7:31 
GeneralRe: srand() Pin
Anders Molin24-Feb-02 11:04
professionalAnders Molin24-Feb-02 11:04 
GeneralRe: srand() Pin
Paul M Watt24-Feb-02 15:03
mentorPaul M Watt24-Feb-02 15:03 
QuestionAnsiString to string w/o changing what is in it? Pin
Steven Richardson24-Feb-02 5:40
Steven Richardson24-Feb-02 5:40 
AnswerRe: AnsiString to string w/o changing what is in it? Pin
Paul M Watt24-Feb-02 15:02
mentorPaul M Watt24-Feb-02 15:02 
GeneralRe: AnsiString to string w/o changing what is in it? Pin
Steven Richardson25-Feb-02 1:33
Steven Richardson25-Feb-02 1:33 
GeneralOpen File Pin
Peter Liddle24-Feb-02 5:06
Peter Liddle24-Feb-02 5:06 
GeneralRe: Open File Pin
24-Feb-02 5:24
suss24-Feb-02 5:24 
GeneralRe: Open File Pin
Peter Liddle24-Feb-02 5:41
Peter Liddle24-Feb-02 5:41 
GeneralShell_NotifyIcon problem => Pin
24-Feb-02 4:44
suss24-Feb-02 4:44 
GeneralRe: Shell_NotifyIcon problem => Pin
Tim Smith24-Feb-02 5:17
Tim Smith24-Feb-02 5:17 
QuestionCan anybody explan the function TransparentBlt()? Pin
ilavl24-Feb-02 4:23
ilavl24-Feb-02 4:23 
AnswerRe: Can anybody explan the function TransparentBlt()? Pin
Jay Beckert24-Feb-02 5:14
Jay Beckert24-Feb-02 5:14 
AnswerRe: Can anybody explan the function TransparentBlt()? Pin
Georg Haan24-Feb-02 6:07
Georg Haan24-Feb-02 6:07 
GeneralRe: Can anybody explan the function TransparentBlt()? Pin
Hadi Rezaee17-May-02 0:03
Hadi Rezaee17-May-02 0:03 
GeneralCall a function in a DLL Pin
Rickard Andersson2024-Feb-02 3:11
Rickard Andersson2024-Feb-02 3:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.