Faster Computers Forums
FasterComputers.com
Quick Member Login:
Forgot password?
Forum Sponsors:
becomeasponsor



Test your Internet connection speed

becomeasponsor
Forum Statistics:
Forum Members: 152
Total Threads: 278
Total Posts: 1,226


There are 2 users
currently browsing forums.
You don't appear to be registered. Click here to register
Search the forums:

Faster Computers Forums » Hardware Forums » General Hardware » c++ random number generator

Notices

Reply
 
LinkBack Thread Tools Display Modes
Old 06-07-2009, 02:20 AM   #1 (permalink)
Noob Member
 
Join Date: Jun 2009
Posts: 25
PAPY2000 is on a distinguished road

Default c++ random number generator

When i try using the random number generator I receive two errors
the first one:missing type specifier - int assumed. Note: C++ does not support default-int
the second : 'srand' : redefinition; previous definition was 'function'

i have the ctime lib being called

to declare the generator I have: This line i copied from another program that works fine.
srand (time(0));

the program then goes to a function called GetTheNumber()
in main I have it coded as generated = GetTheNumber();

in the GetTheNumber function
int GetTheNumber ()
{
int generated;
generated = 1 + rand() % 1000;
return generated;
}

I want the numbers betweet 1 and 1000 randomly generated.

When I look at the other program everything looks the same. Any help would be appreciated

Thanks in advance
PAPY2000 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -4. The time now is 02:16 PM.
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright © FasterComputers.com