Category : dynamic-memory-allocation

1. Code #include<iostream> int main() { int a=3; int *p=new int[a]; } Compilation result NO error compiles fine 2. Code #include<iostream> int main() { int a=3; int (*p)[2]=new int[a][2]; } Compilation result NO error compiles fine 3. Code #include<iostream> int main() { int a=3,b=2; int (*p)[b]=new int[a][b]; } Compilation result Error: Array size in new-expression ..

Read more

I have declared a structure variable which is a dynamic array of another structure but the program crashes every time. Where am I doing wrong? What are the necessary steps to be taken? I am using DEVC++. #include<iostream> #include<cstdlib> using namespace std; struct Project{ int pid; string name; }; struct employee{ int eid; string name; ..

Read more