The #include file for randomness
stdlib.h
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
#include <stdlib.h>
#include <time.h>
...
srand((unsigned int)time(0));
...
int RandBetweenOneAndTen = (rand()/(double)RAND_MAX)*10+1;
#include <time.h>
...
srand((unsigned int)time(0));
...
int RandBetweenOneAndTen = (rand()/(double)RAND_MAX)*10+1;
[twitter]warrenm[/twitter]
Cool, thanks. But can someone also help with this code:
There''s a parse error on line 29 before ''return''
#include <iostream.h>
#include <stdlib.h>
int const MAXIMUM_VALUE = 70;
int StarAt (int nGalaxy, int nX, int nY)
{
int x, y, nReturn;
srand (nGalaxy);
for (y = 0; y <= nY; y++)
{
for (x = 0; x < nX; x++)
{
nReturn = rand() % MAXIMUM_VALUE;
}
}
}
return nReturn; //line 19
}
int main()
{
return 0;
}
There''s a parse error on line 29 before ''return''
#include <iostream.h>
#include <stdlib.h>
int const MAXIMUM_VALUE = 70;
int StarAt (int nGalaxy, int nX, int nY)
{
int x, y, nReturn;
srand (nGalaxy);
for (y = 0; y <= nY; y++)
{
for (x = 0; x < nX; x++)
{
nReturn = rand() % MAXIMUM_VALUE;
}
}
}
return nReturn; //line 19
}
int main()
{
return 0;
}
June 08, 2002 10:05 PM
You have 3
{
but you also have 4
}
.
Get rid of the last { before line 19 and you should be set. Your compiler is currently reading line 19 as outside of any function which is why it''s so confused.
{
but you also have 4
}
.
Get rid of the last { before line 19 and you should be set. Your compiler is currently reading line 19 as outside of any function which is why it''s so confused.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement