I am trying to use the default random generator in C.
the funcion rand() is fine but when tried 'srand(time(0))' it is giving me the following error:
error C3861: 'time': identifier not found
the code I am tryin it in is as follows:
#include <stdio.h>
#include <stdafx.h>
#include <iostream>
#include <stdlib.h>
int main(void)
{
int i, m, x[100];
printf("\n\nEnt er the length of the array: ");
scanf_s("%d", &m);
for(i=0; i<m; i++) x[i]=0;
for(i=0; i<m; i++) x[i]=srand(time(0)) ;
printf("\n\n");
for(i=0; i<m; i++) printf(" %d", x[i]);
printf("\n\n");
}
the funcion rand() is fine but when tried 'srand(time(0))' it is giving me the following error:
error C3861: 'time': identifier not found
the code I am tryin it in is as follows:
#include <stdio.h>
#include <stdafx.h>
#include <iostream>
#include <stdlib.h>
int main(void)
{
int i, m, x[100];
printf("\n\nEnt er the length of the array: ");
scanf_s("%d", &m);
for(i=0; i<m; i++) x[i]=0;
for(i=0; i<m; i++) x[i]=srand(time(0)) ;
printf("\n\n");
for(i=0; i<m; i++) printf(" %d", x[i]);
printf("\n\n");
}
Comment