hi all,
can anyone explain me please why this line of code doesn't generate
any compiler error ( both on vs2005 and kdevelop ).
printf("%s") , "aaa";
this look totaly wrong ( or am i mistaken ).
You are "mistaken".
A statement may be an expression:
void f(){ 1+2; } // is valid C or C++.
An expression may be a list of expressions separated by commas:
1,2,3 // is a valid expression, whose value is 3.
void f(){ 1,2,3; } // is valid C or C++.
If any subexpression in such a sequence has a side effect, so much
good for you
int f(int x){ return x++,x*=2,printf("%d",x),x-1; } // is valid C or C++.
(And contrarily to:
g(x++,x*=2,printf("%d",x),x-1)
the expression:
(x++,x*=2,printf("%d",x),x-1)
has a totally well specified order of evaluation).
Therefore printf("%s"),"aaa" is a valid expression,
therefore printf("%s"),"aaa"; is a valid statement;
it calls the function printf with as argument a pointer to a vector of
three characters '%', 's', 0. and then it results in a pointer to a
vector of four characters, 'a', 'a', 'a' and 0, which it promptly ignores.