C中的printf(带有5个百分号的符号给出错误) [英] printf in c (with five % sign gives error)

查看:316
本文介绍了C中的printf(带有5个百分号的符号给出错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<stdio.h>

int main()
{
pritnf("%%%%%");
}



我已经编写了这段代码,结果是



i have written this code and the out put is

/tmp/ccBawjSg.o: In function `main':
percent.c:(.text+0x11): undefined reference to `pritnf'
collect2: ld returned 1 exit status


为什么会这样?
这意味着什么???
如果有人知道,请回答


抱歉,我错误地执行了错误的代码

实际上是


why this is so???
and what does this means????
please if anybody knows this then answer


sorry guys by mistake i have executed the wrong code

actualy it is

#include<stdio.h>
int main()
{
printf("%%%%%");
}


而警告是
崩溃

percent.c:在"main"函数中:
percent.c:5:警告:格式末尾的乱码%"

并且输出仅是"%%",为什么不是"%%%%%"

[/Edit]


and the warning is
Collapse

percent.c: In function ‘main’:
percent.c:5: warning: spurious trailing ‘%’ in format

and output is only "%%" why not it is "%%%%%"

[/Edit]

推荐答案

这是因为您的代码中有错字.您编写的是"pritnf"而不是"printf".
It''s because there is a typo in your code. You wrote "pritnf" rather than "printf".


%"字符表示格式规范的开始.为了打印单个%"字符,您需要在格式字符串中指定"%%".

请参见此处 [
The ''%'' character indicates the start of a format specification. In order to print a single ''%'' character, you need to specify "%%" in the format string.

See here[^] for more details.


这篇关于C中的printf(带有5个百分号的符号给出错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆