I need to write a program, that will ask a user to enter a number of how many ints they would like to enter.. so the output would look like
Enter number of Ints (mus
After you read numInts
, you allocate the array like so:
int* arr = malloc(numInts*sizeof(int));
Now you populate the array with your already existing function and assigning the values read to the array.
I'm not going to give you a full solution, since this is homework and wouldn't help you, but you access the i
'th element of the array with the []
operator:
arr[i];
Learn more about pointers and calloc