Another Question...memory allocation
1) Which of the following would correctly allocate enough memory to store N integers? The integer pointer in this question is p and N is an integer with a value greater than 0 but not so large taht the amount of memory requested exceeds the amount available.
A. p = (int*)malloc(sizeof(int) + N);
B. p = (int*)malloc(sizeof(int * N));
C. p = (int*)malloc(sizeof(int) * N);
I haven't really worked with memory allocation...but i'm going to make a guess here. I don' think its A because that would just be adding the number of integers to the size of int.
B would actually change the value of the number and C multiplies the size of the int times the number of ints...so i guess C makes the most sense? I don't really have a clue though...
Thanks in advance!