Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
srand()
- Page 1
Re: Trying to animate sprite using DirectX9
Programming
Software Development
4 Weeks Ago
by Pavel_11
Hello, it is unneccessarily to use right movex or leftmovex , because it is to much variables. You should to use one variable movex to make it with minus or plus sign in your update function; by pressing left or right keys; because the one thing which is changable is a picture; I mean in global sense; variables like leftx, right x should be one…
Re: srand function
Programming
Software Development
16 Years Ago
by Narue
…url] will give you an idea of how rand and
srand
work together, but the simple answer is that you …should call
srand
once: [code=c] #include <stdio.h> #include … + rand() % 10; } int main ( void ) { int i; /* Call
srand
only once */
srand
( (unsigned)time ( NULL ) ); for ( i = 0; i < 10…
Re: what is srand?
Programming
Software Development
13 Years Ago
by Ancient Dragon
…numbers, which is the default if the program never calls
srand
(). To get rand() to generate a different set of …to call time() function from time.h, like this: [icode]
srand
( time(0) );[/icode] you might have to typecast the … to unsigned int if your compiler complains about it. What
srand
() does not do: that function does NOT set the lower…
Re: Using srand() and generating characters
Programming
Software Development
12 Years Ago
by Ancient Dragon
srand
() is used to seed the random number generator [icode]
srand
( time(0));[/icode] calling time() will make
srand
() seed with a different number each time the program is run. There is no such thing as an infinite character.
Re: rand vs srand
Programming
Software Development
14 Years Ago
by NathanOliver
srand
() seeds the rand() function. a good way to get a … should be used as follows for general uses [code=c++] //...
srand
(time(NULL)); value = rand() % 365 + 1; //... [/code] you will need…
Random Numbers Help
Programming
Software Development
17 Years Ago
by s.j.macleod
{
srand
((unsigned)time(0)); int random_integer; int lowest=-10, highest=10; …
Re: shuffling and dealing cards program
Programming
Software Development
13 Years Ago
by MattyRobot
srand
sets the seed for the random number generator (it takes the number you put in and passes it through a logarithm which generates a pseudo(fake, not totaly random) set of numbers). setting it by time(), you almost never get the same seed twice and so GREATLY improves randomness.
Re: Call for Help
Programming
Software Development
14 Years Ago
by Ancient Dragon
srand
() doesn't return a value. All that function does is … the random number generator. What you want is rand(), not
srand
().
srand
() should be called only once at the beginning of the… random number. [code] #include <time.h> int main() {
srand
( time(0) ); int n = rand(); } [/code] Note that rand() returns…
Re: can not pass a random number to cout
Programming
Software Development
14 Years Ago
by jonsca
srand
[B]is[/B] the seeding function. You do not need …
Re: random
Programming
Software Development
11 Years Ago
by ravenous
`
srand
` doesn't generate a random number, it sets the seed …
Re: C++ Random Library
Programming
Software Development
17 Years Ago
by Ancient Dragon
>>
srand
((unsigned) time(&t)); you don't need the argument to time() [code]
srand
((unsigned) time(NULL)); [/code] >>#if defined(_MSC_VER) delete the above line and the corresponding #endif. time functions and rand functions are both standard c/c++ library functions that are supported by most c or c++ compilers.
Re: Correction
Programming
Software Development
15 Years Ago
by h3xc0de
srand
((unsigned int)time(NULL));
Re: conditional statement issue
Programming
Software Development
14 Years Ago
by Salem
>
srand
((unsigned)time(0)); Run at full speed, how much time … of constants, therefore your code always does the same thing.
srand
() should be called [B]ONCE ONLY[/B] at the beginning…
Re: Call for Help
Programming
Software Development
14 Years Ago
by Aia
srand
() returns void. You are trying to assign that void return to a float. No, no! [CODE]
srand
( (unsigned)time(NULL) );[/CODE] That's all you need before you call rand()
Re: ERROR time_t to unsighned int
Programming
Software Development
11 Years Ago
by Sky Diploma
srand
( static_cast<unsigned int>( time( NULL ) ) ); Just to add up on the above point. Maybe its time for the static_cast to kick in and try a safe conversion :)
Re: problem with g++ compiler
Programming
Software Development
16 Years Ago
by WolfPack
srand
is a standard C++ function. So g++ also supports it. What is the problem you are getting?
Re: Rand function not working very well.
Programming
Software Development
14 Years Ago
by mrnutty
>>
srand
(unsigned(time(NULL))); You only need to do this once. Put that statement inside main, and just call it once. It only needs to be called once.
Re: Hi I really needed help for this number guessing game
Programming
Software Development
13 Years Ago
by +_+man
srand
(time(NULL)); it can also be used
Re: Simple C program help please?
Programming
Software Development
10 Years Ago
by Ancient Dragon
srand
() should only be called once during the lifetime of the …
Re: Random Number
Programming
Software Development
17 Years Ago
by Ancient Dragon
srand
() seeds the random number generator, you should call
srand
() one time only and near the top of main(). Most of us use the time() function as the paramter to
srand
() [code] int main() {
srand
(time(0)); } [/code]
Re: C++ Random Code Generator
Programming
Software Development
11 Years Ago
by vijayan121
> `
srand
(time(NULL));` Not a good idea to reseed the linear … function is called. Perhaps something like: `static int seed_once = ( std::
srand
( std::time(0) ), 0 ) ;` instead. Or better still, just document… std::rand() is used; and expect `main()` to call `std::
srand
()`. C++11: #include <string> #include <random>…
Re: Math Tutoring Program
Programming
Software Development
17 Years Ago
by sugantha
srand
() takes a seed as an argument and in this case...the system's time is the seed which naturally keeps varying ....so you get a true random number simulation....there are so many other algos to generate random numbers....you can refer a good algorithm text....place
srand
(time(NULL)) anywhere before the rand() function
Re: Random number generation
Programming
Software Development
16 Years Ago
by Narue
>
srand
(time()); 1) You forgot to include time.h, which hides #… seed ); unsigned time_seed ( void ); int is_done ( void ); int main ( void ) {
srand
( time_seed() ); do { double r = uniform_deviate ( rand() ) * RANGE; printf ( "My…
Re: need advices for good programming practise
Programming
Software Development
13 Years Ago
by mrnutty
srand
and rand are in [i]cstdlib[/i]. That is what … library for the time function to generate different seed for
srand
every run. And the difference between "3" and…
Re: Generating Latin Squares
Programming
Software Development
14 Years Ago
by jonsca
srand
(time(0)) goes before rand() and then you don't …
Re: Rand() error
Programming
Software Development
14 Years Ago
by Dave Sinkula
srand
. once. at the beginning.
Re: Console Pong!
Programming
Software Development
13 Years Ago
by helpingdeed
srand
( static_cast<unsigned (time(NULL)) );// its also work fine plz if u can help me a little and tell me how can i cout<<"asdfjkl"<<endl;// if space key is press not enter thank you
Re: Random number
Programming
Software Development
10 Years Ago
by chubbyy.putto
srand
( (unsigned int) time(0)); for (int index = 0; index < …
Re: Randomization in PHP
Programming
Game Development
3 Years Ago
by Reverend Jim
srand
([ int $seed ] ) : void Seeds the random number generator with seed or with a random value if no seed is given.
sRand()
Programming
Software Development
13 Years Ago
by crapgarden
… what the < > operators are doing? [CODE]
srand
(static_cast<unsigned int>(time(0))); [/CODE] I realize… an unsigned int, but why not do this: [CODE]
srand
(unsigned int = time(0));[/CODE] I realize my questions…;ctime> using namespace std; int main() { //Roll 1
srand
(static_cast<unsigned int>(time(0))); //seed random number…
1
2
3
17
Next
Last
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC