int* create_random_array(int n){
int arr[n];
srand(0);
for (int i = 0; i < n; i++)
{
// Fill with random ints 1-100
arr[i] = (rand() % 100)+1;
}
return arr;
}
int main( void ){
int* create_random_array(int n);
int *arr[10];
*arr = create_random_array(10);
for (int i = 0; i < 10; i++)
{
printf("%d\n",arr[i]);
}
}
I am very new to C and programming in general. I am just struggling to understand how to print the array created from a function with pointers.
Here is what I am trying to print:
4
5
2
3
98
12
23
12
23
23
Instead I am printing:
1346144960
1346145216
260272128
1708622408
1346145232
0
0
0
0
0
Any hep would be greatly appreciated, thank you in advance.