char * p = "ram" ;
if( p == "ram")
{
int i= 1;
}
char* q = new char[4];
memset(q,0,4);
memcpy(q,"ram",3);
if( q == "ram")
{
int i=2;
}
In the above code snippet in C++, I found that in
case1,
if condition evaluates to true and it enters the
condition1 while in
case2 when I was allocating
q pointer dynamically then
if condition evaluates to
false and it does not enter in the
condition2. Can anyone please explain this behaviour of
char* with equality operator.