GMP Native Interface for .NET
gmp_libgmp_vfscanf Method |
Read from 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)

public static int gmp_vfscanf( ptr<FILE> fp, string fmt, params Object[] ap )
Public Shared Function gmp_vfscanf ( fp As ptr(Of FILE), fmt As String, ParamArray ap As Object() ) As Integer
public: static int gmp_vfscanf( ptr<FILE>^ fp, String^ fmt, ... array<Object^>^ ap )
static member gmp_vfscanf : fp : ptr<FILE> * fmt : string * ap : Object[] -> int
Parameters
- fp
- Type: Math.Gmp.NativeptrFILE
File stream. - fmt
- Type: SystemString
Format string. See Formatted Input Strings. - ap
- Type: SystemObject
Arguments.
Return Value
Type: Int32The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.

// Create unique filename and stream pointer. string pathname = System.IO.Path.GetTempFileName(); ptr<FILE> stream = new ptr<FILE>(); mpz_t z = "0"; mpq_t q = "0"; mpf_t f = "0"; ptr<Char> c = new ptr<Char>('0'); ptr<mp_size_t> zt = new ptr<mp_size_t>(0); ptr<Double> dbl = new ptr<Double>(0); // Write string to file, and then read values from it. System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000"); _wfopen_s(out stream.Value.Value, pathname, "r"); Assert.IsTrue(gmp_lib.gmp_vfscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); fclose(stream.Value.Value); // Assert values read. Assert.IsTrue(z.ToString() == "123456"); Assert.IsTrue(q.ToString() == "123/456"); Assert.IsTrue(f.ToString() == "0.12345e11"); Assert.IsTrue(c.Value == 'A'); Assert.IsTrue(zt.Value == 10); Assert.IsTrue(dbl.Value == 1.0); // Release unmanaged memory. gmp_lib.mpz_clear(z); gmp_lib.mpq_clear(q); gmp_lib.mpf_clear(f);
' Create unique filename and stream pointer. Dim pathname As String = System.IO.Path.GetTempFileName() Dim stream As New ptr(Of FILE)() Dim z As mpz_t = "0" Dim q As mpq_t = "0" Dim f As mpf_t = "0" Dim c As New ptr(Of[Char])("0"C) Dim zt As New ptr(Of mp_size_t)(0) Dim dbl As New ptr(Of[Double])(0) ' Write string to file, and then read values from it. System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000") _wfopen_s(stream.Value.Value, pathname, "r") Assert.IsTrue(gmp_lib.gmp_vfscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6) fclose(stream.Value.Value) ' Assert values read. Assert.IsTrue(z.ToString() = "123456") Assert.IsTrue(q.ToString() = "123/456") Assert.IsTrue(f.ToString() = "0.12345e11") Assert.IsTrue(c.Value = "A"C) Assert.IsTrue(zt.Value = 10) Assert.IsTrue(dbl.Value = 1.0) ' Release unmanaged memory. gmp_lib.mpz_clear(z) gmp_lib.mpq_clear(q) gmp_lib.mpf_clear(f)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
