%d是什么意思?

phoenixsailor 2004-01-01 07:59:43
我是一个初学者,在做程序的时候不懂%d什么意思,请指教
...全文
37066 38 打赏 收藏 转发到动态 举报
写回复
用AI写文章
38 条回复
切换为时间正序
请发表友善的回复…
发表回复
为什么需要这 2021-07-14
  • 打赏
  • 举报
回复 5

吃我一记洛阳铲!

12s 2004-01-04
  • 打赏
  • 举报
回复
楼上的兄弟,我还没来呢!我觉得楼主是个高手....拿一个简单的问题来担误大家的时间.可是为了分,没办法呢
bangba 2004-01-04
  • 打赏
  • 举报
回复 1
UP
scoutman 2004-01-04
  • 打赏
  • 举报
回复 5
%d 表示整数,通常在printf()里出现,例如:

int x=40;
printf("x is %d", x);

这里x被以整数的形式输出.
其他的形式还有:

%d 整数
%f 浮点数
%c 字符
%s 字符串
.....
建议楼主去看看书,会比我写的清楚。
ch26 2004-01-04
  • 打赏
  • 举报
回复
languagec 2004-01-04
  • 打赏
  • 举报
回复
该结贴了 楼主!

再不结就扣信誉分了

sharkhuang 2004-01-04
  • 打赏
  • 举报
回复
这样的问题不要问了!看书啊
aalng 2004-01-04
  • 打赏
  • 举报
回复
...............
recover 2004-01-04
  • 打赏
  • 举报
回复
好大的坑
fireball64 2004-01-04
  • 打赏
  • 举报
回复
格式符。
nobush 2004-01-04
  • 打赏
  • 举报
回复 2
%d 在格式化字符串里面是代表十进制整数。d 是 decimal 的缩写。
通常在输入输出函数中:
如:printf("%d",x); scanf("%d",&x);
在程序编译时,系统会把%d换在相应的变量,如printf("%d",x)打印一个整数,值由后边的x给出,也就是把x替换%d.

csj6214499 2004-01-03
  • 打赏
  • 举报
回复
%d 是以十进制来输出整数
dreamboy329 2004-01-03
  • 打赏
  • 举报
回复
%d 表示在输出输入时数据类型为整型
comefirst 2004-01-03
  • 打赏
  • 举报
回复
好好看书去吧
独孤过儿 2004-01-03
  • 打赏
  • 举报
回复
我也是初学者,所以我会告诉你我所知道的一切。
%d 是以十进制来输出整数。例如:

a=5;/*赋值语句*/
printf("This is the number %d.",a);

该程序执行的结果为。在屏幕上输出:

This is the number 5.

在这个例子中,%d 的位置实际上就是变量 a 的值。在所有的输出输入语句中都是这样的,你可以就把那个位置看成是后面的变量或者别的数据类型的值就可以了。
proccc 2004-01-03
  • 打赏
  • 举报
回复
***********************
wonderlandsh 2004-01-03
  • 打赏
  • 举报
回复
。。。。。。。。。。
为什么需要这 2021-07-14
  • 举报
回复
@wonderlandsh 精辟
aiknh 2004-01-03
  • 打赏
  • 举报
回复
呵呵~~~我也是初学啊。
大家以后多多帮忙,谢了
bambooeric 2004-01-03
  • 打赏
  • 举报
回复 1
人家是初学者,也不要这样说他吗
cloudtarget 2004-01-02
  • 打赏
  • 举报
回复 1

printf Type Field CharactersThe type character is the only required format field; it appears after any optional format fields. The type character determines whether the associated argument is interpreted as a character, string, or number. The types C and S, and the behavior of c and s with printf functions, are Microsoft extensions and are not ANSI compatible.

printf Type Field Characters

Character Type Output format
c int or wint_t When used with printf functions, specifies a single-byte character; when used with wprintf functions, specifies a wide character.
C int or wint_t When used with printf functions, specifies a wide character; when used with wprintf functions, specifies a single-byte character.
d int Signed decimal integer.
i int Signed decimal integer.
o int Unsigned octal integer.
u int Unsigned decimal integer.
x int Unsigned hexadecimal integer, using "abcdef."
X int Unsigned hexadecimal integer, using "ABCDEF."
e double Signed value having the form [ – ]d.dddd e [sign]ddd where d is a single decimal digit, dddd is one or more decimal digits, ddd is exactly three decimal digits, and sign is + or –.
E double Identical to the e format except that E rather than e introduces the exponent.
f double Signed value having the form [ – ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision.
g double Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than –4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it.
G double Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate).
n Pointer to integer Number of characters successfully written so far to the stream or buffer; this value is stored in the integer whose address is given as the argument.
p Pointer to void Prints the address of the argument in hexadecimal digits.
s String When used with printf functions, specifies a single-byte–character string; when used with wprintf functions, specifies a wide-character string. Characters are printed up to the first null character or until the precision value is reached.
S String When used with printf functions, specifies a wide-character string; when used with wprintf functions, specifies a single-byte–character string. Characters are printed up to the first null character or until the precision value is reached.
加载更多回复(17)

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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