Skip to content

sscanf

builtin · libnexusinterp/corefcn/file-io-proprietary.cc

: [a, count, errmsg, pos] = sscanf (str, template)
: [a, count, errmsg, pos] = sscanf (str, template, size)
: [v1, v2, …, count, errmsg] = sscanf (str, template, "C")

Read formatted data from the string str.

The template may hold the conversions %d %i %u %o %x %f %e %g %s %c %[…], %%, and the usual suppression (%*d) and width modifiers. The template is reused until the input or size is exhausted, or a mismatch occurs.

size is a count n, or [m, n] (n may be Inf). The result is a numeric column unless all conversions are character conversions, in which case it is a char row. count is the number of conversions performed, errmsg a failure message (empty on success) and pos the 1-based index of the next unread character.

With "C" instead of size each conversion is returned as a separate output.