从用C打印内存字节 [英] Print bytes from memory in C
本文介绍了从用C打印内存字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C:
给定一个的地址的(中六),并和INT的 N 的,我怎么能打印第一的 N 的距离的地址?我已经跑了快速谷歌搜索,但没有发现任何相关的信息,我不知道是否有一些特殊的功能,这是否还是我应该使用系统调用?
谢谢!
解决方案
INT N =< num_of_bytes&GT I = 0;,;
无符号字符* BYTE_ARRAY =地址;而(I< N)
{
打印(%02X(无符号)BYTE_ARRAY [I]);
我++;
}
在这里或从其他人计算器一个非常好的重复的回答:
如何可视字节,C / C ++
In C: Given an address (in hexa) and and int n, how can I print the first n bytes starting from address? I've ran a fast google search, but didn't find any relevant info, and I'm not sure if there's some special function that does this or should I use system calls?
Thanks!
解决方案
int n=<num_of_bytes>, i =0;
unsigned char* byte_array = address;
while (i < n)
{
print("%02X",(unsigned)byte_array[i]);
i++;
}
or here is a really nice duplicate answer from other people on stackoverflow: How to visualize bytes with C/C++
这篇关于从用C打印内存字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文