本文介绍了c - 接收%x格式说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个小问题。我知道%x格式说明可用于从一个格式化字符串攻击堆栈读取值。
I have a small question. I know that the %x format specifier can be used to read values from the stack in a format string attack.
我发现下面的code:
I found the following code:
%08x%08x%08x%08x
什么是08呢?它是什么做的是什么呢?感谢:)
What does the 08 mean? What is it doing exactly? Thanks :)
推荐答案
击穿:
-
8
说,你想显示8位数 -
0
要preFIX与0
的,而不是仅仅空格 -
X
要在小写的十六进制打印。
8
says that you want to show 8 digits0
that you want to prefix with0
's instead of just blank spacesx
that you want to print in lower-case hexadecimal.
简单的例子(感谢Grijesh肖汉):
Quick example (thanks to Grijesh Chauhan):
#include <stdio.h>
int main() {
int data = 29;
printf("%x\n", data); // just print data
printf("%0x\n", data); // just print data ('0' on its own has no effect)
printf("%8x\n", data); // print in 8 width and pad with blank spaces
printf("%08x\n", data); // print in 8 width and pad with 0's
return 0;
}
输出:
1d
1d
1d
0000001d
另请参阅http://www.cplusplus.com/reference/cstdio/printf/以供参考。
这篇关于c - 接收%x格式说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!