I have never done anything with dynamic memory allocation and was trying to allocate enough memory to hold four elements of an array. Each of these elements will hold another array that will hold the actual data.
My questions is how can I check the size of a variable to make sure there is enough memory allocated. I am not talking about using an if statement. I would like the actual value of how much memory the variable uses.
//Declaration of variable
int *matrices = NULL; //Pointer to the set of matrix registers
matrices = (int*) malloc(4 * sizeof(int));
I was thinking that if I use printf statement and the dereferencing operator with the variable then I could see the value 16. But I continue to see the number 4. This occurs if I change sizeof(int) to char, float, double, etc. Any ideas would be helpful.
1 Year Ago
Related Article:Access violation in PLA program.
is a C discussion thread by niyasc that has 1 reply, was last updated 1 year ago and has been tagged with the keywords: access, allocation, memory, pla, tabulation, violation.