What is the difference between int * a=new int[n] and int a[n]…is it that in the second case the array is stored in the stack?
New keyword vs a[n]
hello @diganta_7777 yes right.
the first array is dynamically allocated whereas the second array is statically allocated.
in dynamic allocation the memory is allocated during the run time whereas in static the memory is allocated before the program execution.
How does the compiler know what n is then i.e. what will be the size of array that the compiler will keep for the array (for a[n])?
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.