Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ scanf(3W) — Motorola System V 88k Release 4 Version 4.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

printf(3W)

scanf(3S)

stdio(3S)

vprintf(3W)

widec(3W)

scanf(3W)  —  MISC. REFERENCE MANUAL PAGES

NAME

scanf, fscanf, sscanf − convert formatted input

SYNOPSIS

#include <stdio.h>
#include <widec.h> int scanf(const char ∗format [, pointer] ... ); int fscanf(FILE ∗stream, const char ∗format [, pointer] ... ); int sscanf(char ∗s, const char ∗format [, pointer] ... );

DESCRIPTION (International Functions)

scanf() reads from the standard input stream stdin.  fscanf() reads from the named input stream.  sscanf() reads from the character string s.  Each function reads characters (bytes), interprets them according to a control string format, and stores the results in its arguments. 

The control string usually contains conversion specification, which are used to direct interpretation of input sequences.  The control string may contain:

A.  White-space characters (characters are defined in isspace() of ctype(3C)).  Except in two cases described below, these cause input to be read up to the next non-white-space character. 

B.  An ordinary character (any EUC character , except the ASCII character %), which must match the next byte of the input stream. 

C.  Conversion specifications which direct the conversion of the next input field.  Only ASCII characters are allowed as conversion characters. 

The conversion code indicates the interpretation of the input field, and the corresponding pointer argument must match the type being read.  wc and ws are the new conversion specifications for wchar_t character control, and both may be used in all three functions. 

wc A wchar_t character is expected; the character, which should be in EUC, is transformed into a wchar_t character, and stored in the location pointed to by the corresponding argument which should be a wchar_t pointer.  The normal skip over white space is suppressed in this case.  To read the next non-space character as the wchar_t character, %1ws should be used.  If a field width is given, the corresponding argument should refer to a wchar_t array; the indicated number of wchar_t characters are read. 

ws A wchar_t string is expected; characters in EUC are transformed into wchar_t characters and stored in the location pointed to by the corresponding argument.  The corresponding argument should be a pointer pointing to a wchar_t array large enough to accept the string and a terminating wchar_t null character, which is added automatically.  wchar_t characters are read until the number of wchar_t characters specified in the field width, if supplied, or a white-space character is read. 

The conversion of these functions terminate at EOF or a NULL character in the case of sscanf(), at the end of the control string, or when an input character conflicts with the control string.  In the last case, the offending character is left unread in the input stream. 

These functions return the number of successfully matched and assigned input items; this number can be zero in the event of an early conflict between an input character and the control string.  If the input ends before the first conflict or conversion, EOF is returned. 

WARNING

A character from a supplementary code set in a scanset enclosed in a pair of square brackets is simply interpreted as a byte string.  Each byte of the input field is compared to the byte in the scanset. 

SEE ALSO

printf(3W), scanf(3S), stdio(3S), vprintf(3W), widec(3W). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026