简体   繁体   English

C中的格式说明符

[英]Format Specifier in C

What does %p format specifier in C means? C中的%p格式说明符是什么意思? How does it get interpreted in a printf statement? 如何在printf语句中解释它?

For example, when i run the following line in GCC compiler, 例如,当我在GCC编译器中运行以下行时,

int a=1; int a = 1; printf("%p",a); printf(“%p”,a);

the o/pi got is: 00000001 So what does the 8 digits mean? o / pi得到的是:00000001那么8位数字是什么意思?

%p - Print a void * (pointer to void) in an implementation-defined format (Source: http://en.wikipedia.org/wiki/Printf#Format_placeholders ). %p以实现定义的格式打印void *(指向void的指针)(来源: http : //en.wikipedia.org/wiki/Printf#Format_placeholders )。

Most implementations use a hexademical string representation of the value. 大多数实现使用值的十六进制字符串表示形式。

It means to print a value as a hexadecimal representation of a pointer. 这意味着将值打印为指针的十六进制表示形式。 See http://linux.die.net/man/3/printf 参见http://linux.die.net/man/3/printf

这意味着相应的参数是一个指针。

It's for printing pointers. 它用于打印指针。 You pass a pointer to void; 您将指针传递给void; exactly how it will look when it's printed isn't specified by the standard. 该标准并未指定确切的打印时外观。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM