Click or drag to resize
gmp_libgmp_fprintf Method
Print to the stream fp.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static int gmp_fprintf(
	ptr<FILE> fp,
	string fmt,
	params Object[] args
)

Parameters

fp
Type: Math.Gmp.NativeptrFILE
File stream.
fmt
Type: SystemString
Format string. See Formatted Output Strings.
args
Type: SystemObject
Arguments.

Return Value

Type: Int32
Return the number of characters written, or -1 if an error occurred.
Examples
// Create unique file pathname and a file pointer.
string pathname = System.IO.Path.GetTempFileName();
ptr<FILE> stream = new ptr<FILE>();

mpz_t z = "123456";
mpq_t q = "123/456";
mpf_t f = "12345e6";
mp_limb_t m = 123456;

// Open file stream and print to it.
_wfopen_s(out stream.Value.Value, pathname, "w");
Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
fclose(stream.Value.Value);
Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");

// Release unmanaged memory.
gmp_lib.mpz_clear(z)
gmp_lib.mpq_clear(q)
gmp_lib.mpf_clear(f)
See Also