I know that in language like c I need to free the memory after I allocate it. ( I am coming from java), regarding this I have a couple of questions:
when I am doing:
int array[30];
(i.e creating an array of size 30 integers) is this the same as doing?
int array[] = malloc(sizeof(int)*30);
As a sequence to the first question, when I create array(s) inside a function (i.e local to the function and not global to the whole file), do I need to free the memory for this array inside the function where I create it? (I don't see any other way to free it since I can't pass a reference of all arrays created back to the main() function).
So in short, i want to know exactly when do I need to free memory for objects/primitives created (in or outside of a function).