Taken from http://www.ocf.berkeley.edu/~wwu/riddles/cs.shtml
It looks very compiler specific to me. Don't know where to look for?
Taken from http://www.ocf.berkeley.edu/~wwu/riddles/cs.shtml
It looks very compiler specific to me. Don't know where to look for?
You could try preprocessor directives, but that might not be what they are looking for.
Simple enough.
Or is there a requirement to do this without the official standard?
I'm guessing the intent is to write something that depends on differences between the languages themselves, not just predefined macros. Though it's technically not absolutely guaranteed to work, something like this is probably closer to what's desired:
Here's the program:
And here is some nice reading on C and C++ differences.
For what it's worth, here's another answer:
Just look to see if the
__STDC__
and__cplusplus
compiler macros are defined.