wu :: forums
« wu :: forums - Nested Comments »

Welcome, Guest. Please Login or Register.
May 19th, 2024, 9:10am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: william wu, Grimbal, ThudnBlunder, Icarus, towr, SMQ, Eigenray)
   Nested Comments
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Nested Comments  (Read 905 times)
william wu
wu::riddles Administrator
*****





   
WWW

Gender: male
Posts: 1291
Nested Comments  
« on: Apr 12th, 2003, 1:58pm »
Quote Quote Modify Modify

Write a C program that prints "true" if the compiler handles nested comments, and "false" if not.
 
Source: Yosen Lin
« Last Edit: Apr 12th, 2003, 6:32pm by william wu » IP Logged


[ wu ] : http://wuriddles.com / http://forums.wuriddles.com
Pietro K.C.
Full Member
***





115936899 115936899    
WWW

Gender: male
Posts: 213
Re: Nested Comments  
« Reply #1 on: Apr 13th, 2003, 9:23am »
Quote Quote Modify Modify

How about this? I'm not sure if a non-nested-comment compiler will accept it, though, because of the */ left over at the end.

int main() {
 
   int a = 1;
 
/* /**/ a = 0; /**/ */
 
if(a == 1) { printf("true"); }
 else printf("false");
 
return 1;
 
}
« Last Edit: Apr 13th, 2003, 9:24am by Pietro K.C. » IP Logged

"I always wondered about the meaning of life. So I looked it up in the dictionary under 'L' and there it was --- the meaning of life. It was not what I expected." (Dogbert)
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: Nested Comments  
« Reply #2 on: May 29th, 2004, 4:00pm »
Quote Quote Modify Modify

int nested(){
    return 1/* /**/ *0*/*1* /**/1;
}
 
if nested:
    return 1/* /**/ *0*/*1* /**/1;
    return 1*1* 1;
 
if not nested:
    return 1/* /**/ *0*/*1* /**/1;
    return 1 *0*1;
IP Logged
tseuG
Junior Member
**





   


Gender: male
Posts: 62
Re: Nested Comments  
« Reply #3 on: Jul 12th, 2004, 9:08am »
Quote Quote Modify Modify

 Another approach:
 

 
char *truth = /* /* */ " */ " /* " /* */;
 
if nested comments work, truth = " /* "
if they don't, truth = " */ "
 
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board