Inside a program loop
if we write
*ch1++
it will give "lvalue required" error
but without any loop if we write even
++*ch1++;
it will not give any lvalue error. Why?
++*ch1++ = ++(*(ch1++)) which is equal to *(ch1++)= (*(ch1++))+ 1
*ch1++ here lvalue is not present
https://stackoverflow.com/questions/22603763/how-to-check-that-behavior-is-undefined-in-c
#include <stdio.h> int main() { int c=10, *ch=&c, i=10; *ch++; while(i--){ *ch++; } printf("Hello, World!\n%d", *ch++); return 0; }
This code isnt giving lvalue required error. I executed it on coding ground as well as online gdp. Isn't it what you were asking for?
int main() { int c=10, *ch=&c, i=10; int count=0; while(*ch++){ printf("hey\n"); if(count++==3)break; } return 0; }
No error at all. its printing hey 4 times as expected :/