D
duggydiggy
int main()
{
char arr[]={1,2,3,4};
char *c=arr;
*c++='x'; // works fine
*(c+1)++='9'; // l-value needed case 1
void *ptr=arr;
*((char *)ptr+1)=8; // works fine
*((char *)ptr)++=8; //l-value needed case 2
*((char *)ptr+1)++=8;//l-value needed case 3
return 0;
}
1.Can somebody explain the reasons behind these specially case 1 and
case 2
2.Is the reason for case 1 and case 3 same,means compilers using
intermediate objects for offset calculations,and I am applying ++ on
that object,not the use of casting operator
3.Cast operators and ++ operator return a non l-value objects,what
does this mean?
Thanks in advance.
Cheers!!
{
char arr[]={1,2,3,4};
char *c=arr;
*c++='x'; // works fine
*(c+1)++='9'; // l-value needed case 1
void *ptr=arr;
*((char *)ptr+1)=8; // works fine
*((char *)ptr)++=8; //l-value needed case 2
*((char *)ptr+1)++=8;//l-value needed case 3
return 0;
}
1.Can somebody explain the reasons behind these specially case 1 and
case 2
2.Is the reason for case 1 and case 3 same,means compilers using
intermediate objects for offset calculations,and I am applying ++ on
that object,not the use of casting operator
3.Cast operators and ++ operator return a non l-value objects,what
does this mean?
Thanks in advance.
Cheers!!