本文介绍了从缓冲区读取数据!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
我们可以在不知道其DATATYPE的情况下从带有地址的缓冲区读取数据并在控制台上打印该数据吗?
例如我有一个缓冲区89F25F30的地址.现在,我想从此缓冲区读取数据.我也不知道数据的数据类型.之后,我想在控制台上打印该数据. (我正在Windows平台上工作)
现在告诉我有可能吗?如果是,怎么办?
请帮助我.这只是我项目的最后一步.
谢谢大家
Naveen Kumar Dushila
Hello Friends,
Can we read data from a Buffer with its Address and Print that data on the Console Without knowing its DATATYPE??
e.g. I have an Address of a Buffer 89F25F30. Now I want to read data from this buffer. I don''t know the datatype of data too. After that I want to print that data on the console. (I am working on windows platform)
Now tell me is it possible or not? If yes, how?
Please Help me out of this. Its just Last Step of my project.
Thank you all
Naveen Kumar Dushila
推荐答案
int x = 0x12345678;
int buffLen = 4; // you can set it according to your buffer length.
unsigned char *p = (unsigned char *)&x; // you can use here your buffer's address instead of &x
for(int i = 0; i < buffLen; i++)
{
printf("\n Value at location \t%X is\t%X", p, *p);
p++;
}
// warning this may cause segmentation fault.
printf("%X", (unsigned char)array_item[i]);
或
or
printf("%hhX", (char)array_item[i]);
)
这篇关于从缓冲区读取数据!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!