Navigation

Operators and Keywords

Function List:

C++ API

: [val, count, errmsg] = fscanf (fid, template, size)
: [v1, v2, …, count, errmsg] = fscanf (fid, template, "C")

In the first form, read from fid according to template, returning the result in the matrix val.

The optional argument size specifies the amount of data to read and may be one of

Inf

Read as much as possible, returning a column vector.

nr

Read up to nr elements, returning a column vector.

[nr, Inf]

Read as much as possible, returning a matrix with nr rows. If the number of elements read is not an exact multiple of nr, the last column is padded with zeros.

[nr, nc]

Read up to nr * nc elements, returning a matrix with nr rows. If the number of elements read is not an exact multiple of nr, the last column is padded with zeros.

If size is omitted, a value of Inf is assumed.

A string is returned if template specifies only character conversions.

The number of items successfully read is returned in count.

If an error occurs, errmsg contains a system-dependent error message.

In the second form, read from fid according to template, with each conversion specifier in template corresponding to a single scalar return value. This form is more “C-like”, and also compatible with previous versions of Octave. The number of successful conversions is returned in count

See the Formatted Input section of the GNU Octave manual for a complete description of the syntax of the template string.

See also: fgets, fgetl, fread, scanf, sscanf, fopen.

Package: octave