>Sent: Thursday, August 24, 2017 at 5:32 PM
>From: "Marc Glisse" <[email protected]>
>To: "Piotr Olszewski" <[email protected]>
>Cc: [email protected]
>Subject: Re: GMP crashes when using gmp_scanf to scan an mpf_t.
>On Thu, 24 Aug 2017, Piotr Olszewski wrote:
>
>> The crash happened when I tried to run a piece of code from the manual 
>> (11.1):
>>
>> /* to read say "topleft (1.55,-2.66)" */
>> mpf_t x, y;
>> char buf[32];
>> gmp_scanf ("%31s (%Ff,%Ff)", buf, x, y);
>>
>> I placed it in a main function and added a line to print the scanned 
>> information like this:
>>
>> #include <gmp.h>
>> int main(void)
>> {
>> /* to read say "topleft (1.55,-2.66)" */
>> mpf_t x, y;
>> char buf[32];
>> gmp_scanf ("%31s (%Ff,%Ff)", buf, x, y);
>> gmp_printf("%s (%Ff,%Ff)\n", buf, x, y);
>> return 0;
>> }
>
>This is not a snippet meant to be copy-pasted, the declarations are there
>to show the types of the arguments, but you need to mpf_init the variables
>as usual.
>
>--
>Marc Glisse

Thank you, I read that part of the manual a bit out of context so I assumed 
that no initialization was necessary. The program runs correctly now that I 
call mpf_init on both variables before passing them to gmp_scanf.

Regards,
Piotr Olszewski.
_______________________________________________
gmp-bugs mailing list
[email protected]
https://gmplib.org/mailman/listinfo/gmp-bugs

Reply via email to