Custom array length by pointer (new, delete)

 //custom array length

//by new,delete



#include<iostream.h>

#include<cstring>

using namespace std;

int main(int argc, char *argv[])

{

char st[]="hello";

int l=strlen(st);

char* p;

int ll;

cout<<"len";

cin>>ll;

p=new char[ll];

strcpy(p,st);

cout<<p;

delete []p;

return 0;

}

Comments

Popular posts from this blog

ဆိုလာ စနစ္ရွိ BATTERY AMPACITY အား design ထုတ္တြက္ခ်က္ၿခင္း (1) watt hour ရယူၿခင္း

Pointer to object array