char *ptr="abc";
char *ptr1;
while(*ptr1++=*ptr++); //IT IS WORKING
while((*ptr1)++=(*ptr)++); //ERROR
PLS EXPLAIN ME.
[Added [code][/code].]
You haven't initialized ptr1: when you first dereference it, it is already undefined behavior, so "IT IS WORKING" is just plain "luck(?)".
In the "ERROR" line, the result of the ++ operator is not an lvalue, so it cannot be assigned to.
Reputation Points: 2780
Solved Threads: 312
long time no c
Offline 4,790 posts
since Apr 2004