Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

Standard I/O library

Functions


Function Documentation

int _scanf (  const char *  format,
... 
) 
 

Read formatted data from stdin (UART0). 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.

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).
  • 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
    Where the specifier character at the end is the most significant component, since it defines which characters are extracted, their interpretation and the type of its corresponding argument:
  • i I d D Any number of digits, optionally preceded by a sign (+ or -). Decimal digits assumed by default (0-9), but a 0x prefix introduces hexadecimal digits (0-f).
    Signed argument.
  • f A series of decimal digits, optionally containing a decimal point, optionally preceeded by a sign (+ or -) and optionally followed by the e or E character and a decimal integer.
  • c C The next character. If a width other than 1 is specified, the function reads exactly width characters and stores them in the successive locations of the array passed as argument. No null character is appended at the end.
  • s S Any number of non-whitespace characters, stopping at the first whitespace character found. A terminating null character is automatically added at the end of the stored sequence.
Returns:
On success, the function returns the number of items of the argument list successfully filled.
See also:
printf, sprintf

int consoleGetString (  char *  pString  ) 
 

Get a string from stdin (UART0). CR character is used to terminate the input.

Parameters:
pString Pointer to buffer used to store received data.
Returns:
Number of characters received.
See also:
_scanf

int printf (  const char *  format,
... 
) 
 

Writes the C string pointed by format to the standard output (UART0). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

Parameters:
format C string that contains the text to be written to stdout. It can optionally contain embedded format specifiers that are replaced by the values specified in subsequent additional arguments and formatted as requested. A format specifier follows this prototype: %[flags][width][.precision][length]specifier Where the specifier character at the end is the most significant component, since it defines the type and the interpretation of its corresponding argument:
  • d or i Signed decimal integer
  • u Unsigned decimal integer
  • x Unsigned hexadecimal integer
  • X Unsigned hexadecimal integer (uppercase)
  • f Decimal floating point
  • c Character
  • s String of characters
  • % A % followed by another % character will write a single % to the stream.
    The format specifier can also contain sub-specifiers: flags, width, .precision and modifiers (in that order), which are optional and follow these specifications:

    width description:
    (number) Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger.
    .precision description:
    .number For integer specifiers (d, i, u, x, X): precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0. For f specifiers: this is the number of digits to be printed after the decimal point. For s: this is the maximum number of characters to be printed. By default all characters are printed until the ending null character is encountered. If the period is specified without an explicit value for precision, 0 is assumed.
Returns:
On success, the total number of characters written is returned.
See also:
sprintf, _scanf

int sprintf (  char *  out,
const char *  format,
... 
) 
 

Write formatted data to string. Composes a string with the same text that would be printed if format was used on printf, but instead of being printed, the content is stored as a C string in the buffer pointed by str. The size of the buffer should be large enough to contain the entire resulting string. A terminating null character is automatically appended after the content. After the format parameter, the function expects at least as many additional arguments as needed for format.

Returns:
On success, the total number of characters written is returned. This count does not include the additional null-character automatically appended at the end of the string. On failure, a negative number is returned.
See also:
printf, _scanf


Generated on Tue Apr 7 20:07:44 2015 for BF592A Library by doxygen 1.3.1