Reputation: 310
I'm trying to write binary data to a filestream out
which I've opened as std::ios::binary
. I'm trying to write to it using 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));
}
}
}
}
At the moment I'm getting error: expected unqualified-id before ‘sizeof’
in both places I'm trying to write out.
Upvotes: 1
Views: 254
Reputation: 29966
sizeof()
is a language operator, not a part of the standard library, so you can't prefix it with std
:
sizeof(anything)
Upvotes: 4