Why the below code compilation success though dynamic allocation of array is not possible in C++? on uncommenting the comments it shows error??
#include<iostream> #include <string> using namespace std; int main() { string aa; cin>>aa; int a[aa.size()];// though allocating the array dynamically the compilation succeeded cout<<"COMPILATION SUCCESS"<<endl; /*char *p; cin>>p; int y=sizeof(p); int b[y]; cout<<"COMPILATION ERROR"<<endl; */ /* int tt; cin>>tt; int c[tt];// shows error cout<<"ERROR"; */ }
cin<<tt;instead ofcin>>tt;?