作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
typedef struct {
const char *name;
const unsigned char *data;
const unsigned int size;
} Assembly;
void test(const Assembly **assemblies);
void test(const Assembly ** assemblies)
{
//i want to print assemblies to a txt file.
//like this:
//name->XXX
//data->DDD
//size->YYY
}
int main()
{
test(bundled);
return 0;
}
我刚开始学习C,这个任务太难了。 我不知道该怎么做。请帮助我。谢谢!
问题是:
对于每个 char 二进制数组,‘144’更改为 -122
“255”更改为-1。
就像上图一样!
如何获取数据{77, 90, 144, 0, 3, 0, 0, 0, 4, 0, 0, 0, 255, 255} 并将其写入txt文件。
最佳答案
嗯,它是 144.. 你写为 unsigned char (从 0 到 255 ),但看起来你读为 char (从 -128 到 127 )。144 作为无符号字符是[1001000]b。-112,因为 char 是 [10010000]b。你的代码没有任何问题。
关于c - 如何将struct char写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37790508/
我是一名优秀的程序员,十分优秀!