The libraries GMP, how to save the result of the calculation?

Hello, please tell me how when you work with functions from the GMP library, to read and save data to a file (and read from file) for example using Arrays?
In this f-in mpz_init_set_str(), the value is passed directly
And like to consider it from a Binary file using FILE *fp = fope()and also save the result into a Binary file ?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>

int main(void)
{
 mpz_t n, d, e, pt, ct;

mpz_init(pt);
mpz_init(ct);
 mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10);
 mpz_init_set_str(e, "65537", 10);
 mpz_init_set_str(d, "5617843187844953170308463622230283376298685", 10);

 const char *plaintext = "Rossetta Code";
 mpz_import(pt, strlen(plaintext), 1, 1, 0, 0, plaintext);

 if (mpz_cmp(pt, n) > 0)
abort();

 mpz_powm(ct, pt, e, n);
 gmp_printf("Encoded: %Zd\n", ct);

 mpz_powm(pt, ct, d, n);
 gmp_printf("Decoded: %Zd\n", pt);

 char buffer[64];
 mpz_export(buffer, NULL, 1, 1, 0, 0, pt);
 printf("As String: %s\n", buffer);

 mpz_clears(pt, ct, n, e, d, NULL);
 return 0;
}


Read the manuals on GMP - I can not understand.

So far I found only this:
FILE *cfile = fopen("c.txt" , "rw")
 mpz_t c ;
mpz_init(c);

 mpz_inp_str(c, cfile, 10);

 printf("c: ");
 mpz_out_str(stdout, 10, c);


But it is only reading from a file in the Decimal how to read binary.
April 3rd 20 at 18:49
1 answer
April 3rd 20 at 18:51
Solution
when working with the functions from the GMP library, to read and save data to a file (and read from file) for example using Arrays?

To export the pattern/import from array using mpz_export/mpz_import.
This is all, of course, I naturally read these Pallas ' cats, but could not understand, and working examples in the Internet, virtually none.
Like understood, works at Funktsiyakh. - kayleigh_Colli commented on April 3rd 20 at 18:54

Find more questions by tags C