开发者

C code to detect if the compiler allows comments to nest

This is an interview Question that i was asked recently:

Write a C program which when compiled and run, prints out a message indicating whether the compiler that it is compiled with, allows /* */ comments to nest

How t开发者_如何学JAVAo go about this ?


int noNesting = 0 /* /* */ + 1 // */
;


 int main(void)
 {
 int temp=0 /* /* */ + 1 // */
;
    //if nesting allowed temp value woud be 0 otherwise it would be 1
if(temp)
{
printf("Nesting not allowed");
}
else
{
printf("Nesting allowed");
}
return 0;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜