Click here to Skip to main content
15,911,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: I'm hoping some C# Guru out there can help me... (IndexOf and Multidimension Arrays) Pin
Luc Pattyn12-Jun-09 14:58
sitebuilderLuc Pattyn12-Jun-09 14:58 
AnswerRe: I'm hoping some C# Guru out there can help me... (IndexOf and Multidimension Arrays) Pin
Wonde Tadesse12-Jun-09 15:43
professionalWonde Tadesse12-Jun-09 15:43 
GeneralRe: I'm hoping some C# Guru out there can help me... (IndexOf and Multidimension Arrays) Pin
Paul Calabro15-Jun-09 5:14
Paul Calabro15-Jun-09 5:14 
GeneralRe: I'm hoping some C# Guru out there can help me... (IndexOf and Multidimension Arrays) Pin
Wonde Tadesse16-Apr-11 13:48
professionalWonde Tadesse16-Apr-11 13:48 
JokeI'm hoping you eventually hit the right forum... Pin
CPallini12-Jun-09 22:41
mveCPallini12-Jun-09 22:41 
Question[Message Deleted] Pin
xchen199812-Jun-09 7:35
xchen199812-Jun-09 7:35 
AnswerRe: Custom Control Pin
xchen199813-Jun-09 13:44
xchen199813-Jun-09 13:44 
QuestionHelp with rand() definition [modified] Pin
Grimes12-Jun-09 6:58
Grimes12-Jun-09 6:58 
Hello everybody

I am looking for the rand() function definition, because I want to use it to create a similar
function for a super secret project of mine Suspicious | :suss: . I have found a website on the Internet that
claims the rand() function definition is something like:

unsigned long int next = 1;
int rand()
{
   next = next * 1103515245 + 12345;
   return (unsigned int)(next/65536) % 32768;
}


however if I use this function it does not give me the same value as the rand() function.
cout << (rand() %50) << "\n";
cout << (rand() %50) << "\n";

gives the first random value of 41 and second value of 17. (the srand() function was not used so these are the same every time I run the program)

and when I use the definition I got from the website
long unsigned int Getal = 1;
Getal = (Getal*1103515245 + 12345);
cout << (Getal/65536) % 32768 % 50 << "\n";
Getal = (Getal*1103515245 + 12345);
cout << (Getal/65536) % 32768 % 50 << "\n";

the first output is 38 and the second 8.

Maybe there is something wrong with my implementation, or can someone maybe help or tell me what the
correct definition is. I am using Visual C++ 6 and use the rand() function found in the stdlib.h.
Is the data types I used correct? Where can I find the definition in the stdlib.h? I tried looking
there but there's only a line that says "_CRTIMP int __cdecl rand(void);" ?!? Anyway I would
appreciate help

thanks
grimes

KOM UIT DAAAAA!!!

modified on Friday, June 12, 2009 1:04 PM

AnswerRe: Help with rand() definition Pin
Luc Pattyn12-Jun-09 7:14
sitebuilderLuc Pattyn12-Jun-09 7:14 
GeneralRe: Help with rand() definition Pin
Grimes12-Jun-09 7:47
Grimes12-Jun-09 7:47 
AnswerRe: Help with rand() definition Pin
Randor 12-Jun-09 7:16
professional Randor 12-Jun-09 7:16 
GeneralRe: Help with rand() definition Pin
Grimes12-Jun-09 8:02
Grimes12-Jun-09 8:02 
GeneralRe: Help with rand() definition Pin
harold aptroot12-Jun-09 8:50
harold aptroot12-Jun-09 8:50 
GeneralRe: Help with rand() definition Pin
Grimes12-Jun-09 17:03
Grimes12-Jun-09 17:03 
GeneralRe: Help with rand() definition [modified] Pin
T210212-Jun-09 22:57
T210212-Jun-09 22:57 
GeneralRe: Help with rand() definition Pin
Grimes12-Jun-09 23:44
Grimes12-Jun-09 23:44 
GeneralRe: Help with rand() definition [modified] Pin
T210212-Jun-09 23:57
T210212-Jun-09 23:57 
QuestionHow to Custom a papersize during a printer work under windows 2000/xp [modified] Pin
Crazy Wu12-Jun-09 5:40
Crazy Wu12-Jun-09 5:40 
AnswerRe: How to Custom a papersize during a printer work under windows 2000/xp Pin
Crazy Wu12-Jun-09 17:36
Crazy Wu12-Jun-09 17:36 
QuestionConversion Pin
reddy0712-Jun-09 5:08
reddy0712-Jun-09 5:08 
AnswerRe: Conversion Pin
Crazy Wu12-Jun-09 5:48
Crazy Wu12-Jun-09 5:48 
AnswerRe: Conversion Pin
CPallini12-Jun-09 5:51
mveCPallini12-Jun-09 5:51 
AnswerRe: Conversion Pin
Rajesh R Subramanian12-Jun-09 9:20
professionalRajesh R Subramanian12-Jun-09 9:20 
GeneralRe: Conversion Pin
reddy0712-Jun-09 9:30
reddy0712-Jun-09 9:30 
QuestionUsing WMI to get hardware information Pin
Anthony Mushrow12-Jun-09 4:49
professionalAnthony Mushrow12-Jun-09 4:49 

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.