开发者

C code to detect if the compiler allows comments to nest

开发者 https://www.devze.com 2023-03-31 08:55 出处:网络
This is an interview Question that i was asked recently: Write a C program which when compiled and run, prints out a message

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

精彩评论

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