reading binary file content into an mpz_t variable

Sam Rawlins sam.rawlins at gmail.com
Mon Jan 17 17:48:00 CET 2011


On Mon, Jan 17, 2011 at 7:09 AM, Erick Paquin <info at erickpaquin.com> wrote:

> Thanks for all the answers. I'll do some more testing tonight and will send
> in some code if I'm still unsuccessful.
>

Erick,

Sorry if I came off as brief. I think that Rick and Gabriel gave you some
good information to work with. And, in case you are discouraged, people
often can help out a lot if you post a snippet of code. I think people get a
little excited/intrigued when presented with code-with-a-bug.

Please do post back if you get stuck again.

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