reading binary file content into an mpz_t variable
Erick Paquin
info at erickpaquin.com
Mon Jan 17 15:09:17 CET 2011
Thanks for all the answers. I'll do some more testing tonight and will send
in some code if I'm still unsuccessful.
Cheers,
Erick
On Sun, Jan 16, 2011 at 6:02 PM, Erick Paquin <info at erickpaquin.com> wrote:
> Hi Everyone,
>
> Please bear with me as my programming skills are still relatively new.
>
> I've tried a few things but I cannot seem to do what I want.
>
> I would basically like to read the "entire" content of a file (its
> hex/binary content) into an mpz_t variable for later processing.
>
> I've tried with both the mpz_inp_str and the mpz_inp_raw functions and when
> I try to see the number of bytes read from these functions it always either
> returns 0 (as if an error occurred) or it crashes the application with a
> memory segmentation fault.
>
> Actually I am not also 100% sure of how to "read" the size_t returned value
> from the gmp functions (do you assign the function to an int variable and
> read it?). Any help on that too would be awesome.
>
> How would you go about in the simplest way possible read the entire content
> of a file into an mpz_t variable?
>
> I've also tried with fread which actually works but then to transfer the
> content of my fread into an mpz_t variable I couldn't find how.
>
> Any tips?
>
> Thanks,
>
> Erick P.
>
More information about the gmp-discuss
mailing list