Interview Question
Software Engineer / Developers@Anonymous..ur idea is correct. ## concatenates val1 and val2.
However in this case it would throw out an error stating that "val1val2" is not found
But why do we get this error ?
#define FUN(val1,val2) val1##val2
#define SQR(x,y) x##y
int main(int argc, char* argv[])
{
int val1=10;
int val2=20;
printf("%d\n",SQR(val1,val2));
// printf("%d\n",FUN(val1,val2));
return 0;
}
In this code the first printf works properly but the 2nd one fails. Is this because of some peculiarity in the ##operator ?
Output is : 1020
- Anonymous January 23, 2010