在C中使用printf
时,如何转义%符号?
printf("hello\%"); /* not like this */
发布于 2009-12-07 22:06:41
正如其他人所说,%%将转义%。
但是,请注意,您永远不应该这样做:
char c[100];
char *c2;
...
printf(c); /* OR */
printf(c2);
当你必须打印一个字符串时,总是使用
printf("%s", c)
以防止嵌入的%导致问题(内存冲突、segmentation faults等)。
发布于 2009-12-07 22:04:59
发布于 2009-12-07 22:03:59
带着它自己。
printf("hello%%"); /* like this */
https://stackoverflow.com/questions/1860159
复制相似问题