我正在尝试将二进制数据写入文件流 out
,我已将其打开为 std::ios::binary
。我正在尝试使用 ostream::write
写入它。
int S = 0;
int space = htobe32(-120);
for (int g = 0; g < Z; ++g)
{
for (int h = 0; h < Y; ++h)
{
for (int i = 0; i < X; ++i)
{
if (data_array[g][h][i] != 0)
{
S=htobe32(data_array[g][h][i]);
out.write(&S, std::sizeof(S));
}
else
{
out.write(&space, std::sizeof(space));
}
}
}
}
目前我在尝试写出的两个地方都收到了error: expected unqualified-id before ‘sizeof’
。
最佳答案
sizeof()
是一个语言运算符,不是标准库的一部分,所以你不能在它前面加上std
:
sizeof(anything)
关于c++ - 错误 : unqualified ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28342577/