Last active
December 17, 2015 16:08
-
-
Save sanpingz/5636153 to your computer and use it in GitHub Desktop.
C++ comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
/**** 1. backslash-newline ****/ | |
int a = 1; | |
//some comments \ | |
a++; | |
printf("%d\n", a); | |
int b = 1; | |
//some comments ??/ | |
b++; | |
printf("%d\n", b); | |
/\ | |
/ some comments | |
/\ | |
* | |
some comments | |
*/ | |
/**** 2. trigraph sequences ****/ | |
/* | |
---------------------------------------------------------------------------- | |
| trigraph | replacement | trigraph | replacement | trigraph | replacement | | |
---------------------------------------------------------------------------- | |
| ??= | # | ??( | [ | ??< | { | | |
| ??/ | \ | ??) | ] | ??> | } | | |
| ??’ | ˆ | ??! | | | ??- | ˜ | | |
---------------------------------------------------------------------------- | |
*/ | |
printf("seems to work (but is it right??)"); // seems to work (but is it right] | |
/* | |
warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs] | |
g++ demo.cpp -o demo -trigraphs | |
*/ | |
/**** 3. nested comments ****/ | |
//! /*something /* something else */ */ | |
int ans = /*/*/0*/**/1; | |
printf("\n%d\n", ans); | |
#if 0 | |
commments1 | |
#if 0 | |
comments2 | |
#endif | |
commments3 | |
#endif | |
/**** 4. bad comments ****/ | |
/* | |
comments | |
* / | |
code = 1; /* comments !*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment