I am trying to use rand,srand and time to generate random(enough) numbers in C.I use DEVC++.I get the following error: [Linked Error]undefined reference to 'gettimeofday' error
Here is my code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
static unsigned long next = 1;
int myrand(void) {
next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % 32768);
}
void mysrand(unsigned seed) {
next = seed;
}
struct {
long tv_sec;
long tv_usec;
}timeval ;
int main(){
int num=0; //random number
struct timeval t1;
gettimeofday(&t1, NULL);
srand(t1.tv_usec * t1.tv_sec);
arg_num=rand();
printf("Number of arguments is:%d\n",arg_num);
}
Making an online research i found out that DEVC++ (somehow) includes GNU compiler but it doesn't really use it and that results in not identifying all "common" functions. Beyond solving the linked error, i would like to know if there is an IDE for C programming in Windows that uses GNU or that will not making such problems..