#include #include #include using namespace std; //dynamic allocation with pointer // Hello World -- will not overflow //char_new_delete1.cpp int main () { //-------Gracefully set a limit of 15 charcter------- char *ch2; string str1; cout<<"\n address of ch2 "<< &ch2; cout<<"\n Enter a string : "; getline(cin,str1); cout<<"\n string length : " << str1.length(); if(str1.length()>15) { cout<<"\n sorry limit was 15"; delete[] ch2; //exit(1); } else { ch2 = new char[str1.length()]; for(int i= 0; i< str1.length(); i ++) { ch2[i]= str1[i]; } cout<<"\n Allocated : " << ch2 << " @ : " << *ch2 ; delete[] ch2; } return 0; }