🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
using srand()
why do I get this error when I try to get a random nr?
error C2501: ''srand'' : missing storage-class or type specifiers
error C2373: ''srand'' : redefinition; different type modifiers
c:\vc98\include\stdlib.h(308) : see declaration of ''srand''
I use the following code in my program
#include
#include
#include
#include
#include
#include
#include
srand((unsigned)time(NULL)) ;
int block=rand()%7 ;
The only things that can be put outside of a function are declarations (including assignments to global variables).
I don''t get it now (the next day) my function alway returns the same number?!?
srand((unsigned)time(NULL)) ;
void RandomPiece()
{
while (!block)
{
block=rand()%7 ;
}
}
what could be wrong?!?
srand((unsigned)time(NULL)) ;
void RandomPiece()
{
while (!block)
{
block=rand()%7 ;
}
}
what could be wrong?!?
Are you sure your while() loop is ever run ?
In debug mode, variables are initialized by VC++ to a pattern of hexadecimal CCCC''s, so that, when you debug your program, if you see CC''s, you can scream "DUH, uninitialized variable !".
In debug mode, variables are initialized by VC++ to a pattern of hexadecimal CCCC''s, so that, when you debug your program, if you see CC''s, you can scream "DUH, uninitialized variable !".
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement