J.Swersey
J.Swersey

Reputation: 171

Appending bits to a file in C

I'm working on a CRC32 program for a project and I've hit another stumbling block. We get a 32-bit UINT back from the ASM code we have, and in order to test the algorithm, we need to append those exact bits to the end of the text file we threw into the algorithm, and we're kind of at a loss of how to do that. We tried fprint, but that transformed the int into a char and changed the bits. Same deal with fwrite. Is there some way to do this with fwrite we're missing? Any help would be appreciated.

Upvotes: 0

Views: 179

Answers (1)

Joshua
Joshua

Reputation: 43278

You have to open the file in binary mode.

It's also possible you have to flip the bytes (if the ASM code returns them in a different endianness than expected. If the target is big-endian, than htonl will work).

Upvotes: 1

Related Questions