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
Post a Comment