c中的警告消息错误[已关闭]

5jvtdoz2  于 2023-01-16  发布在  其他
关注(0)|答案(1)|浏览(122)

编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
2天前关闭。
Improve this question

warning: unknown escape sequence: '\!' [enabled by default]
  printf("\\ this is a back-slash character\!\n");
         ^
w1p2.c:25:9: warning: unknown escape sequence: '\!' [enabled by default]
  printf("%% this is a percent sign character\!\n");
         ^
w1p2.c:26:9: warning: unknown escape sequence: '\!' [enabled by default]
  printf("\" this is a double - quote character\!\n");

我做了一个简单的printf程序,我不断收到这些消息。
到底是怎么回事,我该怎么解决?
在此之前,我尝试使用\符号,但效果不佳。

yh2wf1be

yh2wf1be1#

到底是怎么回事,我该怎么解决?
只有部分字符可以转义(C11 § 6.4.4.4、§ 6.4.5、§ 6.4.3)。
!不是其中之一,并且打印!不需要\

// printf("\\ this is a back-slash character\!\n");
printf("\\ this is a back-slash character!\n");
//                                       ^

简单转义序列:其中之一

\’ \" \? \\  
\a \b \f \n \r \t \v

八进制转义序列:

\ octal-digit
\ octal-digit octal-digit
\ octal-digit octal-digit octal-digit

十六进制换码序列:

\x hexadecimal-digit
hexadecimal-escape-sequence hexadecimal-digit

通用字符名称:

\u hex-quad
\U hex-quad hex-quad

相关问题