I've encountered a problem when trying to print mpq_t data type in GMP. Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
int main(){
mpq_t a;
mpq_init(a);
mpq_set_str(a, "41/152", 10);
gmp_printf("the rational is: %Q\n",a);
return 0;
}
But it only prints out "the rational is: Q". I've followed the GMP manual(https://gmplib.org/manual/Formatted-Output-Strings.html), but couldn't find the bug. Help is much appreciated!
A
d
(stands for decimal) is missing after theQ
: