怎样输出一个 % 号到缓冲中啊?

ququshb 2002-09-09 02:38:39
char buffer[50];
::Zeromemory(buffer,50)
printf(buffer, ????);

我想让 buffer 中的内容为 "This is %d."
那个 %d 是buffer中的内容
该怎么做啊
...全文
25 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ququshb 2002-09-09
  • 打赏
  • 举报
回复
试了下
只能用 %%
不能用 \%d %\0x64
原因如下%[flags] [width] [.precision] [{h | l | I64 | L}]type

Each field of the format specification is a single character or a number signifying a particular format option. The simplest format specification contains only the percent sign and a type character (for example, %s). If a percent sign is followed by a character that has no meaning as a format field, the character is copied to stdout. For example, to print a percent-sign character, use %%.

谢谢大家
albert 2002-09-09
  • 打赏
  • 举报
回复
printf("This is %% %d.", ????);
miaoweijun 2002-09-09
  • 打赏
  • 举报
回复
%%d

sans 2002-09-09
  • 打赏
  • 举报
回复
printf( "This is %%d.");
sans 2002-09-09
  • 打赏
  • 举报
回复
printf( "This is \%d");
everandforever 2002-09-09
  • 打赏
  • 举报
回复
...
\\ Backslash
\? Literal question mark
\ooo ASCII character in octal notation
\xhhh ASCII character in hexadecimal notation
用户 昵称 2002-09-09
  • 打赏
  • 举报
回复
%%
everandforever 2002-09-09
  • 打赏
  • 举报
回复
printf(buffer, "This is %\x064.");
anothervip 2002-09-09
  • 打赏
  • 举报
回复
%%d 可以吗?

或者:"%% %c",'d'

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧