When memory is allocated dynamically, is it stored on the heap no matter where it was declared? For example, if the following line of code is declared inside main()
int* p = new int[100000];
will memory be allocated from heap or stack?
If the same declaration is made in global scope, memory will be obtained from the heap. But I read that dynamically allocated memory is stored on the heap and local variable are stored on the stack. So when the above line of code is executed from inside of main, which makes it a local variable, will memory be obtained from the stack or heap?