Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<time.h>

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
does <time.h> work in this? i need to use this:

randomize();

and i supposedly need to include <time.h> at the beginning for this to work.. and the error keeps saying error C2065: 'randomize' : undeclared identifier

what am i doing wrong?
 
hi.
<time.h>
This file has declarations of time routines and defines the structure returned by the localtime and gmtime routines and used by asctime.

this fiel has not declarations at randomize.
 
Hi nanimo

As far as I'm aware, Visual C++ doesn't have a randomize() function. That was only in the old Borland Turbo C++. The way to randomize in VC++ is by using the ANSI srand() function, which takes a longint &quot;seed&quot; argument.

For reasonable randomness, this seed can be taken from the time() command, making it dependant on the exact time at which that line of code is run.

The command would therefore be:
srand(time(NULL));

Both functions are ANSI C++ which means they are also portable.
srand is in stdlib.h
time is in time.h

Hope this helps :)
 
yeah, thanks thats why it wasn;t working- we are using bordland turbo c++ in class and i have been using this one at home.. so i guessed some things might be different..
thanks everyone!!
 
I've included stdlib.h and then I used srand and got these errors:

: error C2501: 'srand' : missing storage-class or type specifiers
: error C2373: 'srand' : redefinition; different type modifiers

Any idea why this is happening?? *Suzanne*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top