1.
array = (int *) malloc(N*sizeof(int));
- Correct
array = (int *) malloc(N*int);
- Not quite. Try again!
N = (int *) malloc(array*sizeof(int));
- Not quite. Try again!
(int *) array = N*malloc(sizeof(int));
- Not quite. Try again!
Suppose you would like to reserve space in memory for an array of N integers (where N is a variable of type
int
that holds the number of ints to be stored) and store the resulting location in an integer pointer (an int *
)arraythat has already been declared. What is the correct way to do so?