int a = srand(time(NULL));
The prototype for srand
is void srand(unsigned int)
(provided you included <stdlib.h>
).
This means it returns nothing … but you’re using the value it returns (???) to assign, by initialization, to a
.
Edit: this is what you need to do:
#include <stdlib.h> /* srand(), rand() */ #include <time.h> /* time() */ #define ARRAY_SIZE 1024 void getdata(int arr[], int n) { for (int i = 0; i < n; i++) { arr[i] = rand(); } } int main(void) { int arr[ARRAY_SIZE]; srand(time(0)); getdata(arr, ARRAY_SIZE); /* ... */ }