L
linq936
Hi,
I am reading book <<Expert C Programming>>, it has the following
quiz,
a //*
//*/ b
In C and C++ compiler what does the above code trun out?
I think it is simple for C compiler, it is a/b.
But for C++ compiler, the book says it is a. The reason is "//"
makes the rest of line comment.
I am wondering on this.
Just couple page back, it mentions that compiler has a "maximal
munch strategy". For me when the C++ compiler reads the 1st line,
there is ambiguous intepretation, it could be "a// *" or "a / /*",
then if we apply the "maximal much strategy", it should use the second
one and parse the code to
a / /*
// */ b
which is a/b.
I think I am confused at somewhere, could you shed some light?
Thanks.
I am reading book <<Expert C Programming>>, it has the following
quiz,
a //*
//*/ b
In C and C++ compiler what does the above code trun out?
I think it is simple for C compiler, it is a/b.
But for C++ compiler, the book says it is a. The reason is "//"
makes the rest of line comment.
I am wondering on this.
Just couple page back, it mentions that compiler has a "maximal
munch strategy". For me when the C++ compiler reads the 1st line,
there is ambiguous intepretation, it could be "a// *" or "a / /*",
then if we apply the "maximal much strategy", it should use the second
one and parse the code to
a / /*
// */ b
which is a/b.
I think I am confused at somewhere, could you shed some light?
Thanks.