Binary to mpz_t
jamesb.au at ozemail.com.au
Sun Oct 26 02:11:23 CEST 2003
I'd like to ask if anyone knows how I can slurp in binary data from a file
and convert it into an mpz_t big int. For example, I'd like to open a file
in binary mode:
f = fopen("file.bin", "rb");
and suck in 512 bytes, i.e. a typical disk sector:
unsigned char stuff;
fread(stuff, sizeof(char), 512, f);
and then use whatever's in stuff to make the big int. I'd like it to
interpret the 512-bit long bit pattern as an unsigned integer. I'd also
like to be able to write it back out as a 512-bit long bit pattern.
How can I do this?
More information about the gmp-discuss