I'm having a bit of trouble with this random number generation function. It's going to be part of a much larger program which requires lots of random numbers so I decided to use time as a seed. However I can't seem to get this to work. This code is virtually taken from my lecturers notes and I have tried a lot of variations but can't figure what's wrong.
Here's the code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main()
{
int random, seed, time;
seed = (int) time(NULL);
random = rand(seed);
printf("random number = %d\n", random);
return (0);
}
Hope someone can help!