P
Pranav
#include<stdio.h>
#include<conio.h>
int main()
{
const int i=6;
int k = 9;
int a, *c = a, *v = a ;
a[2] = 9;
*c++ = *v++; // ( 1 ) This line does not generate any exception /
error
k++ = k++; // ( 2 ) But this line is generating
k++ = 6; // ( 3 ) This Also Generating
getch();
}
Now I know that you cannot assign a value to an expression; But why
does the above (1) expression not generating a exception/error/
warning? and (2) & (3) are generating as they are supposed to. Please
explain this.
Is this due to operator precedence in the case(1), ie the expression
access the value and then assign them and then increment the pointers
and move forward. Correct if I am wrong..,
(I am using DevC++ Compiler for testing)
#include<conio.h>
int main()
{
const int i=6;
int k = 9;
int a, *c = a, *v = a ;
a[2] = 9;
*c++ = *v++; // ( 1 ) This line does not generate any exception /
error
k++ = k++; // ( 2 ) But this line is generating
k++ = 6; // ( 3 ) This Also Generating
getch();
}
Now I know that you cannot assign a value to an expression; But why
does the above (1) expression not generating a exception/error/
warning? and (2) & (3) are generating as they are supposed to. Please
explain this.
Is this due to operator precedence in the case(1), ie the expression
access the value and then assign them and then increment the pointers
and move forward. Correct if I am wrong..,
(I am using DevC++ Compiler for testing)