我正在尝试将我的号码保存在文件中,但程序不断崩溃:
include stdio.h
include mpir.h
int main(void){
mpf_set_default_prec(32); //Default precision for floating points
mpf_t my_number;
mpf_init_set_str(my_number, "5.12345e0", 10); //Set my_number to 5.123 with decimal base (10)
FILE *f;
f = fopen("some.txt", "w");
gmp_printf("Printed number to screen: %.*Ff \n", 32, my_number);
//Everything works until I try to save it to file:
gmp_fprintf(f, "My saved number is: %.*Ff \n", 32, my_number);
fclose(f);
return 0;
}
而不是 fprintf 我试过:
gmp_fscanf(f, "%F", &zbroj)
mpz_out_str(f, 10, zbroj)
sprintf(f, "%F", zbroj)