Alright guys, I'm teaching myself C with help from "C for dummies 9 in 1 reference guide" and I'm going through and I am stumped on one of the codes the author provided.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
long int hat;
int loop;
long int seed;
printf("Enter a seed number:");
scanf("%d",&seed);
srandom(seed);
for(loop=0;loop<100;loop++)
{
hat = rand();
printf("%5d is a truly random number!\n",hat);
}
return(0);
}
That is the code that I have typed into Dev-C++ and it's saved as a ".c" but when I compile I get the following errors:
[Linker error] undefined reference to `random'
[Linker error] undefined reference to `srandom'
So my question is why does it pull up this error? How do I go about fixing it? Also why does dev-c++ not like the "random();" function, which is I used "rand();"?
~Tirith