But if I go for array of char the it works.
So what exactly the new operator forcing not to replace the contect.
Code:
#include <iostream>
using namespace std;
int main(void)
{
char *pA=new char[10]="Raj";
char *pB1;
char pB2[10]="aaa";
cout<<pA<<endl;
pB1=pB2;
char *q = pB1;
while(*pB1++ = *pA++);
*pB1 = '\0';
cout<<q<<endl;
return 0;
}
By the way if I write like
char *pA= new char[10];
p="Raj"
Then also the meaning is same.It is first reserving memory for 10 char Then giving the address of "Raj' to the pointer. Now p contains the address of "Raj".
This is a test program. Just to copy the string using new.