我正在制作一个从程序中删除注释的 C 程序...所以我想知道 '//'
、'/*'
和 '*\'
是否被视为 1 个字符(如 \t
, \n
\b
) 或者它们被当作 2 个字符(字面意思,即 /(1)/(2)
)谢谢:)
'//'
等多字符字符常量是有效的,但具有实现定义的值。
请注意,剥离 C 注释很困难。这是我在 C 注释剥离器上使用的酷刑测试的一部分:
"And escaped double quotes at the end of a string\""
aa '\\
n' OK
aa "\""
aa "\
\n"
This is followed by C++/C99 comment number 1.
// C++/C99 comment with \
continuation character \
on three source lines (this should not be seen with the -C flag)
The C++/C99 comment number 1 has finished.
This is followed by C++/C99 comment number 2.
/\
/\
C++/C99 comment (this should not be seen with the -C flag)
The C++/C99 comment number 2 has finished.
This is followed by regular C comment number 1.
/\
*\
Regular
comment
*\
/
The regular C comment number 1 has finished.
/\
\/ This is not a C++/C99 comment!
This is followed by C++/C99 comment number 3.
/\
\
\
/ But this is a C++/C99 comment!
The C++/C99 comment number 3 has finished.
我是一名优秀的程序员,十分优秀!