When I try to run the following code, I get this error:
'initializing': cannot convert from 'void *' to 'int *'
I'd like to return an array of casual numbers from 1 to 10 from the function but I can't figure out how to do it, can you help me? The IDE underlines 'malloc'.
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <conio.h>
#include <time.h>
int* casuali(int n);
int main()
{
int n = 10;
int* arrCasuali = casuali(n);
for (int i = 0; i < n; i++)
{
printf("%d", arrCasuali[i]);
}
}
int* casuali(int n)
{
int* arrCasuali = malloc(sizeof(int) * n);
srand(time(NULL));
for (int i = 0; i < n; i++)
{
arrCasuali[i] = rand() % 10 + 1;
}
return arrCasuali;
}