reading binary file content into an mpz_t variable

Sam Rawlins sam.rawlins at gmail.com
Mon Jan 17 03:32:33 CET 2011


On Sun, Jan 16, 2011 at 4: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.
>

Without seeing your code, this is impossible to debug.


> 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.
>

Here too; need to see your code.


>
> Any tips?
>
> Thanks,
>
> Erick P.
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>



-- 
Sam Rawlins


More information about the gmp-discuss mailing list