Declaration of long int*
Hi, I'm trying to use this piece of code as a random number generator:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
float ran0(long *idum)
{
long k;
float ans;
*idum ^= MASK;
k=(*idum)/IQ;
*idum=IA*(*idum-k*IQ)-IR*k;
if (*idum < 0) *idum += IM;
ans=AM*(*idum);
*idum ^= MASK;
return ans;
}
|
which requires passing of a long*.
In my main, I fail to declare a long*. This is what I wrote:
1 2 3 4 5 6 7 8
|
int main()
{
float rand = 0;
long *seed = 123;
rand = ran0(seed);
cout << "The answer is" << rand ;
return 0;
}
|
And the error code is:
ran0.cpp: In function `int main()':
ran0.cpp:30: invalid conversion from `int' to `long int*'
|
Please advise how to declare it, thank you.
Topic archived. No new replies allowed.