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

serial to parallel test with 74c595 and pic mcu

INTERRUPT_ON_CHANGE_18f4550