Why am I getting “void value not ignored as it ought to be”?

I have the following function :

void getdata(int arr[], int n)
{

    for (int i = 0; i < n; i++) 
    {
        int a = srand(time(NULL));
        arr[i] = a;
    }
}

And I call it in main:

getdata(arr, 1024);

I get “void value not ignored as it ought to be” but I don’t understand what is wrong.Why do I get this error?

Leave a Comment