此代码有什么问题
typedef unsigned char datum; /* Set the data bus width to 8 bits. */
datum pattern;
datum antipattern;
antipattern = ~pattern;
Remark[Pa091]: operator operates on value promoted to int (with possibly unexpected result) C:\filepath...\file.c 386
Run Code Online (Sandbox Code Playgroud)
编译器是IAR EWARM,为什么需要将两个char变量转换为int。当所有内容都声明为未签名时,为什么还要抱怨符号更改。
任何想法都可以用来摆脱此警告吗?
在 C# 中将二维数组写入文件的最简单方法是什么?
到目前为止,我读到的所有问题都是针对字符串数组的,但我需要写入数据。我正在转换一个旧的 C 项目,在 C 中很容易:
FILE *file;
unsigned char site[32][10];
Run Code Online (Sandbox Code Playgroud)
初始化数组并打开文件进行读/写(该文件始终在项目中打开):
写入数据:
if (fseek (file, offset, SEEK_SET))
return (0);
return (fwrite (&site, sizeof (site), 1, file));
Run Code Online (Sandbox Code Playgroud)
要读取数据:
if (fseek (file, offset, SEEK_SET))
return (0);
return (fread (&site, sizeof (site), 1, fsite));
Run Code Online (Sandbox Code Playgroud)
该文件不必一直打开,所以我试过:
byte [,] = new byte[32,10] = { some data here };
File.WriteAllBytes(fileDescr, site);
Run Code Online (Sandbox Code Playgroud)
但是它不适用于二维数组。