Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

Scanf Lite - Read formatted data from stdin


Files

file  otScanfLite.h
 Scanf Lite Library.

Modules

 Version History

Functions

void setStdin (U8 chan)
 Set the standard input. Use UART0, UART1.
int scanf (const char *format,...)
 Read formatted data from stdin. Reads data from stdin and stores them according to the parameter format into the locations pointed by the additional arguments. The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier within the format string.
int sscanf (const char *str, const char *fmt,...)
 Reads data from s and stores them according to parameter format into the locations given by the additional arguments, as if scanf was used, but reading from s instead of the standard input (stdin).
int vsscanf (const char *str, const char *fmt, va_list ap)
 Read formatted data from string into variable argument list.

Detailed Description

Dependency: SERIAL - Procedure for serial usage

Function Documentation

int scanf const char *  format,
  ...
 

Parameters:
format C string that contains a sequence of characters that control how characters extracted from the stream are treated: Whitespace character: the function will read and ignore any whitespace characters encountered before the next non-whitespace character (whitespace characters include spaces, newline and tab characters -- see isspace). A single whitespace in the format string validates any quantity of whitespace characters extracted from the stream (including none). Non-whitespace character, except format specifier (): Any character that is not either a whitespace character (blank, newline or tab) or part of a format specifier (which begin with a character) causes the function to read the next character from the stream, compare it to this non-whitespace character and if it matches, it is discarded and the function continues with the next character of format. If the character does not match, the function fails, returning and leaving subsequent characters of the stream unread. Format specifiers: A sequence formed by an initial percentage sign () indicates a format specifier, which is used to specify the type and format of the data to be retrieved from the stream and stored into the locations pointed by the additional arguments.
A format specifier for scanf follows this prototype: specifier
-s for C string
-d and -u for decimal numbers
-f for floating point single precision -x for hex numbers -c for characters
... Depending on the format string, the function may expect a sequence of additional arguments, each containing a pointer to allocated storage where the interpretation of the extracted characters is stored with the appropriate type. There should be at least as many of these arguments as the number of values stored by the format specifiers. Additional arguments are ignored by the function. These arguments are expected to be pointers: to store the result of a scanf operation on a regular variable, its name should be preceded by the reference operator (&).
Returns:
On success, the function returns the number of items in the argument list successfully filled.

void setStdin U8  chan  ) 
 

Parameters:
chan 
See also:
UartId

int sscanf const char *  str,
const char *  fmt,
  ...
 

Parameters:
str C string that the function processes as its source to retrieve the data.
fmt C string that contains a format string that follows the same specifications as format in scanf (see scanf for details).
... Depending on the format string, the function may expect a sequence of additional arguments, each containing a pointer to allocated storage where the interpretation of the extracted characters is stored with the appropriate type.
Returns:
On success, the function returns the number of items in the argument list successfully filled.

int vsscanf const char *  str,
const char *  fmt,
va_list  ap
 

Parameters:
str C string that the function processes as its source to retrieve the data.
fmt C string that contains a format string that follows the same specifications as format in scanf (see scanf for details).
ap Depending on the format string, the function may expect a sequence of additional arguments, each containing a pointer to allocated storage where the interpretation of the extracted characters is stored with the appropriate type.
Returns:
On success, the function returns the number of items in the argument list successfully filled.
footer

otStudio - Library Reference - (C) 2020-23 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0