PDA

View Full Version : My first serious topic

C++
05-14-2003, 03:07 AM
Hello! This topic is serious. I using Borland C++ Builder 6.0 just because of I don`t know where is random() function in Visual C++ 7.0. I searched RANDOM function in all (*.*) VC`s files (FULL INSTALL), but nowhere found it. Please, help me, if you know in which header lays RANDOM function for generation random numbers.

knackered
05-14-2003, 03:53 AM
*sigh*

#include <stdlib.h>

srand(666);
int mynumber = rand();

// mynumber will be a number between 0 and RAND_MAX (defined in stdlib.h). You can then convert it to any range you like.

From MDSN:
The rand function returns a pseudorandom integer in the range 0 to RAND_MAX. Use the srand function to seed the pseudorandom-number generator before calling rand.

VikingCoder
05-14-2003, 05:44 AM
I was going to email C++ privately, but I realized that other people might benefit from this information as well...

C++,

You REALLY need to go to a site like http://www.experts-exchange.com/ to ask questions about random functions, and other things that have absolutely nothing whatsover to do with the specific use of OpenGL.

gvm
05-14-2003, 07:05 AM
Hi!
I have founded this in MSDN's examples:
/* GetRandom returns a random integer between min and max. */
#define GetRandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min))
Also you can use this: (i didn't remember where i founded it...)
float getRandomMinMax( float fMin, float fMax )
{
float fRandNum = (float)rand () / RAND_MAX;
return fMin + (fMax - fMin) * fRandNum;
}
Or use:
srand(time(NULL));
int random_number = rand()%10; // this will generate number from 0 to 10

rgpc
05-14-2003, 06:19 PM
Originally posted by knackered:
*sigh*

I agree whole heartedly... (Seriously too...)

C++
05-15-2003, 01:04 AM
BEGIN "TO KNACKERED (for his *sigh*)"
(South pole. Beach. Sun. Warm water. Flowers, singing birds... Silence... ... ...
Suddenly! (Intimately))
*breath*
*exhalation*
*breath*
*exhalation*
*breath*
*exhalation*
* -- Oh, boy! More deeply! More deeply!*
(Nice & lovely joke. Without insults, OK?)
END

Hello! Thank you (knackered, gvm) for your answer (very useful). What is MSDN? As far as I`ve understood, MSDN is help database? How much it costs to order it by mail (For example, there where you are living)?

rgpc
05-15-2003, 01:37 AM
(a) It's free

knackered
05-15-2003, 03:27 AM
MSDN is just a searchable database of documents provided free by microsoft to try to help people to be able to write programs under their hellish operating system.
It stands for MicroSoft Developer Network.
Just go here: http://msdn.microsoft.com/

Now please c++, don't post anymore questions here. You're making a fool out of yourself - you're not eloquent enough to be entertaining...this isn't an insult, because your english is certainly better than my russian - it's just advice. From what I gather from your posts, you are a beginner in OpenGL and in Windows programming...that's no problem, everyone has to begin somewhere - but here in this forum is not the proper place to begin.

C++
05-15-2003, 04:54 AM
Hello, knackered! I`m not beginner in Windows programming and I have MSDN. I bought it on 3 CDs in the pirates`s shop and paid \$8. I just found out that MSDN is free for copying.
Why you so hate Windows? I love Windows. Under Windows works all my favourite progs. Probably others OSes works much better but I still love Windows. Please, list (I know nothing about the reason of hatred) some critical lacks of Windows :-)
About posting. OK, I promise I`ll never post even one off-topic (I understand only good form such as your).
About english. Was a time when you didn`t know even a single word in english. And now you strewing thousands of words. Question: why? Answer: because you have unlimited practice in english language evey day. For example, small and ugly american child (Which will in future consume a lot of resources of planet Earth (of course, including russian`s oil) in time when all other childs in the world will not have even a living necessary minimum of food (In Russia and not only but, except of "narrow eyes" (from China) because they breed as rabbits and I`m not fell pity for them)) learn out american language because IT has a practice and hear speech. And I haven`t such opportunities. So, you know english much better than I.
P.S.
"The Chinese army began to penetrate through Russia`s border by small groups. Each group includes one million soldiers."

knackered
05-15-2003, 05:41 AM
Mmm, you're beginning to scare me now, c++.
This is not the place for this kind of talk. Go to flipcode, and rant on to them...they will absolutely love you. http://www.flipcode.com/cgi-bin/msg.cgi?showIndex=randombits&page=0

JONSKI
05-15-2003, 07:16 AM
Originally posted by C++:
I`m not beginner in Windows programming Most of us don't need to tell people this.

Ysaneya
05-15-2003, 08:06 AM
What is MSDN?

I`m not beginner in Windows programming

'Nuff said.

Y.