【发布时间】:2014-03-01 12:22:13
【问题描述】:
我目前正在尝试恢复图像数据,但不是在恢复之前将其写入文本文件,而是想将它们放入数据库中。现在,我写入 4 字节(启动集群),2 字节(标题) , 2byte(data) 到一个文本文件中。
DWORD x = 0;
WORD headerByte = 0;
WORD dataByte = 0;
write(jpg_info,&x,4);
write(jpg_info,&headerByte,2);
write(jpg_info,&dataByte,2);
我打开 jpg_info.txt 后的结果将是(例如): DB 21 00 00 95 05 00 00
但是,当我尝试对字符串使用 memcpy() 时,
char xChar[8];
char headerByteChar[4];
char dataByteChar[4];
memcpy(xChar, &x, 4);
memcpy(headerByteChar, &headerByte, 2);
memcpy(dataByteChar, &dataByte, 2);
我的结果将是: DB 21 95 05
这不是我想要的..我尝试了各种方法,但我永远无法得到相同的结果..
由于 x 只使用 2 个字节的数据,我希望剩余的 2 个字节为 00,即使它只占用 2 个字节的数据。
有没有办法这样做?
对不起,我已经被困在这里好几个星期了!
【问题讨论】:
-
这和C#有什么关系?
标签: c# c data-recovery