In the recent post C string to uppercase in C and C++, the function:
void strupp(char* beg)
{
while (*beg++ = toupper(*beg));
}
showed the undesirable result of 'OOBAR' when given 'foobar' with an answer explaining "there is no sequence point" in the expression. Now I have always been using
char *s1=strTo, *s2= strFrom;
while (*s2) *s1++ = *s2++;
with the understanding it means to get the value of the right part (*s2
), increment s2
; assign the obtained value to *s1
and increment s1
. But it seems that this neither contains a sequence point so that it has always worked would be coincidence (luck), which I can't believe.
Anyone can help me and explain this?