📄 fiolib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/fioLib.html - generated by refgen from fioLib.c --> <title> fioLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>fioLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>fioLib</strong> - formatted I/O library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./fioLib.html#fioLibInit">fioLibInit</a>( )</b> - initialize the formatted I/O support library<br><b><a href="./fioLib.html#printf">printf</a>( )</b> - write a formatted string to the standard output stream (ANSI)<br><b><a href="./fioLib.html#printErr">printErr</a>( )</b> - write a formatted string to the standard error stream<br><b><a href="./fioLib.html#fdprintf">fdprintf</a>( )</b> - write a formatted string to a file descriptor<br><b><a href="./fioLib.html#sprintf">sprintf</a>( )</b> - write a formatted string to a buffer (ANSI)<br><b><a href="./fioLib.html#vprintf">vprintf</a>( )</b> - write a string formatted with a variable argument list to standard output (ANSI)<br><b><a href="./fioLib.html#vfdprintf">vfdprintf</a>( )</b> - write a string formatted with a variable argument list to a file descriptor<br><b><a href="./fioLib.html#vsprintf">vsprintf</a>( )</b> - write a string formatted with a variable argument list to a buffer (ANSI)<br><b><a href="./fioLib.html#fioFormatV">fioFormatV</a>( )</b> - convert a format string<br><b><a href="./fioLib.html#fioRead">fioRead</a>( )</b> - read a buffer<br><b><a href="./fioLib.html#fioRdString">fioRdString</a>( )</b> - read a string from a file<br><b><a href="./fioLib.html#sscanf">sscanf</a>( )</b> - read and convert characters from an ASCII string (ANSI)<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides the basic formatting and scanning I/O functions. Itincludes some routines from the ANSI-compliant <b><a href="./fioLib.html#printf">printf</a>( )</b>/<b><a href="./ansiStdio.html#scanf">scanf</a>( )</b>family of routines. It also includes several utility routines.<p>If the floating-point format specifications <b>e</b>, <b>E</b>, <b>f</b>, <b>g</b>, and <b>G</b> areto be used with these routines, the routine <b><a href="./floatLib.html#floatInit">floatInit</a>( )</b> must be calledfirst. If the configuration macro <b>INCLUDE_FLOATING_POINT</b> is defined,<b><a href="./floatLib.html#floatInit">floatInit</a>( )</b> is called by the root task, <b><a href="./usrConfig.html#usrRoot">usrRoot</a>( )</b>, in <b>usrConfig.c</b>.<p>These routines do not use the buffered I/O facilities provided by thestandard I/O facility. Thus, they can be invoked even if the standard I/Opackage has not been included. This includes <b><a href="./fioLib.html#printf">printf</a>( )</b>, which in most UNIXsystems is part of the buffered standard I/O facilities. Because <b><a href="./fioLib.html#printf">printf</a>( )</b>is so commonly used, it has been implemented as an unbuffered I/O function.This allows minimal formatted I/O to be achieved without the overhead ofthe entire standard I/O package. For more information, see the manualentry for ansiStdio.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>fioLib.h</b>, <b>stdio.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p>ansiStdio, <b><a href="./floatLib.html#top">floatLib</a></b>,<i>VxWorks Programmer's Guide: I/O System </i><hr><a name="fioLibInit"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>fioLibInit( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>fioLibInit( )</strong> - initialize the formatted I/O support library</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void fioLibInit (void)</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initializes the formatted I/O support library. It should becalled once in <b><a href="./usrConfig.html#usrRoot">usrRoot</a>( )</b> when formatted I/O functions such as <b><a href="./fioLib.html#printf">printf</a>( )</b> and<b><a href="./ansiStdio.html#scanf">scanf</a>( )</b> are used.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./fioLib.html#top">fioLib</a></b><hr><a name="printf"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>printf( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>printf( )</strong> - write a formatted string to the standard output stream (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int printf ( const char * fmt, /* format string to write */ ... /* optional arguments to format string */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine writes output to standard output under control of the string<i>fmt</i>. The string <i>fmt</i> contains ordinary characters, which are writtenunchanged, plus conversion specifications, which cause the arguments thatfollow <i>fmt</i> to be converted and printed as part of the formatted string.<p>The number of arguments for the format is arbitrary, but they mustcorrespond to the conversion specifications in <i>fmt</i>. If there areinsufficient arguments, the behavior is undefined. If the format isexhausted while arguments remain, the excess arguments are evaluated butotherwise ignored. The routine returns when the end of the format stringis encountered.<p>The format is a multibyte character sequence, beginning and ending in itsinitial shift state. The format is composed of zero or more directives:ordinary multibyte characters (not <b>%</b>) that are copied unchanged to theoutput stream; and conversion specification, each of which results infetching zero or more subsequent arguments. Each conversion specificationis introduced by the <b>%</b> character. After the <b>%</b>, the following appear insequence:<ul><li>Zero or more flags (in any order) that modify the meaning of the </li>conversion specification.<li>An optional minimum field width. If the converted value has fewer</li>characters than the field width, it will be padded with spaces (bydefault) on the left (or right, if the left adjustment flag, described later, has been given) to the field width. The fieldwidth takes the form of an asterisk (<b>*</b>) (described later) or a decimalinteger.<li>An optional precision that gives the minimum number of digits to</li>appear for the <b>d</b>, <b>i</b>, <b>o</b>, <b>u</b>, <b>x</b>, and <b>X</b> conversions, the number of digits to appear after the decimal-point character for <b>e</b>, <b>E</b>, and <b>f</b>conversions, the maximum number of significant digits for the <b>g</b> and<b>G</b> conversions, or the maximum number of characters to be written from a string in the <b>s</b> conversion. The precision takes the form of a period (<b>.</b>) followed either by an asterisk (<b>*</b>) (described later) or byan optional decimal integer; if only the period is specified, the precision is taken as zero. If a precision appears with any otherconversion specifier, the behavior is undefined.<li>An optional <b>h</b> specifying that a following <b>d</b>, <b>i</b>, <b>o</b>, <b>u</b>, <b>x</b>, and</li><b>X</b> conversion specifier applies to a <b>short int</b> or <b>unsigned short int</b>argument (the argument will have been promoted according to the integralpromotions, and its value converted to <b>short int</b> or <b>unsigned short int</b>before printing); an optional <b>h</b> specifying that a following <b>n</b> conversion specifier applies to a pointer to a <b>short int</b> argument. Anoptional <b>l</b> (ell) specifying that a following <b>d</b>, <b>i</b>, <b>o</b>, <b>u</b>, <b>x</b>, and<b>X</b> conversion specifier applies to a <b>long int</b> or <b>unsigned long int</b>argument; or an optional <b>l</b> specifying that a following <b>n</b> conversionspecifier applies to a pointer to a <b>long int</b> argument. An optional <b>ll</b> (ell-ell) specifying that a following <b>d</b>, <b>i</b>, <b>o</b>, <b>u</b>, <b>x</b>, and<b>X</b> conversion specifier applies to a <b>long long int</b> or <b>unsigned long long int</b> argument; or an optional <b>ll</b> specifying that a following <b>n</b> conversion specifier applies to a pointer to a <b>long long int</b> argument. If a <b>h</b>, <b>l</b> or <b>ll</b> appears with any other conversion specifier, the behavior is undefined.<li></blockquote><h4>WARNING</h4><blockquote><p>ANSI C also specifies an optional <b>L</b> in some of the same</li>contexts as <b>l</b> above, corresponding to a <b>long double</b> argument.However, the current release of the VxWorks libraries does not support <b>long double</b> data; using the optional <b>L</b> gives unpredictable results.<li>A character that specifies the type of conversion to be applied.</li></ul><p>As noted above, a field width, or precision, or both, can be indicated byan asterisk (<b>*</b>). In this case, an <b>int</b> argument supplies the field widthor precision. The arguments specifying field width, or precision, or both,should appear (in that order) before the argument (if any) to be converted.A negative field width argument is taken as a <b>-</b> flag followed by a positivefield width. A negative precision argument is taken as if the precisionwere omitted.<p>The flag characters and their meanings are:<dl><dt><b>-</b><dd>The result of the conversion will be left-justified within the field.(it will be right-justified if this flag is not specified.)<dt><b>+</b><dd>The result of a signed conversion will always begin with a plus or minus sign. (It will begin with a sign only when a negative valueis converted if this flag is not specified.)<dt><b>space</b><dd>If the first character of a signed conversion is not a sign, or if a signed conversion results in no characters, a space will be prefixed to the result. If the <b>space</b> and <b>+</b> flags both appear, the<b>space</b> flag will be ignored.<dt><b>#</b><dd>The result is to be converted to an "alternate form." For <b>o</b> conversionit increases the precision to force the first digit of the result to be azero. For <b>x</b> (or <b>X</b>) conversion, a non-zero result will have "0x" (or"0X") prefixed to it. For <b>e</b>, <b>E</b>, <b>f</b>, <b>g</b>, and <b>g</b> conversions, theresult will always contain a decimal-point character, even if no digitsfollow it. (Normally, a decimal-point character appears in the result ofthese conversions only if no digit follows it). For <b>g</b> and <b>G</b>conversions, trailing zeros will not be removed from the result. Forother conversions, the behavior is undefined.<dt><b>0</b><dd>For <b>d</b>, <b>i</b>, <b>o</b>, <b>u</b>, <b>x</b>, <b>X</b>, <b>e</b>, <b>E</b>, <b>f</b>, <b>g</b>, and <b>G</b> conversions,leading zeros (following any indication of sign or base) are used to padto the field width; no space padding is performed. If the <b>0</b> and <b>-</b>flags both appear, the <b>0</b> flag will be ignored. For <b>d</b>, <b>i</b>, <b>o</b>, <b>u</b>,<b>x</b>, and <b>X</b> conversions, if a precision is specified, the <b>0</b> flag willbe ignored. For other conversions, the behavior is undefined.</dl><p>The conversion specifiers and their meanings are:<dl><dt><b>d</b>, <b>i</b><dd>The <b>int</b> argument is converted to signed decimal in the style<b>[-]dddd</b>. The precision specifies the minimum number of digits to appear; if the value being converted can be represented infewer digits, it will be expanded with leading zeros. Thedefault precision is 1. The result of converting a zero valuewith a precision of zero is no characters.<dt><b>o</b>, <b>u</b>, <b>x</b>, <b>X</b><dd>The <b>unsigned int</b> argument is converted to unsigned octal (<b>o</b>),unsigned decimal (<b>u</b>), or unsigned hexadecimal notation (<b>x</b> or <b>X</b>)in the style <b>dddd</b>; the letters abcdef are used for <b>x</b> conversionand the letters ABCDEF for <b>X</b> conversion. The precision specifiesthe minimum number of digits to appear; if the value being converted can be represented in fewer digits, it will be expanded with leading zeros. The default precision is 1. Theresult of converting a zero value with a precision of zero is no characters.<dt><b>f</b><dd>The <b>double</b> argument is converted to decimal notation in the style <b>[-]ddd.ddd</b>, where the number of digits after the decimalpoint character is equal to the precision specification. If theprecision is missing, it is taken as 6; if the precision is zeroand the <b>#</b> flag is not specified, no decimal-point characterappears. If a decimal-point character appears, at least one digit appears before it. The value is rounded to the appropriatenumber of digits.<dt><b>e</b>, <b>E</b><dd>The <b>double</b> argument is converted in the style <b>[-]d.ddde+/-dd</b>,where there is one digit before the decimal-point character (which is non-zero if the argument is non-zero) and the numberof digits after it is equal to the precision; if the precisionis missing, it is taken as 6; if the precision is zero and the <b>#</b> flag is not specified, no decimal-point character appears. Thevalue is rounded to the appropriate number of digits. The <b>E</b>conversion specifier will produce a number with <b>E</b> instead of <b>e</b>introducing the exponent. The exponent always contains at leasttwo digits. If the value is zero, the exponent is zero.<dt><b>g</b>, <b>G</b><dd>The <b>double</b> argument is converted in style <b>f</b> or <b>e</b> (or in style <b>E</b> in the case of a <b>G</b> conversion specifier), with the precisionspecifying the number of significant digits. If the precisionis zero, it is taken as 1. The style used depends on the value converted; style <b>e</b> (or <b>E</b>) will be used only if the exponent resulting from such a conversion is less than -4 or greater than or equal to the precision. Trailing zeros areremoved from the fractional portion of the result; a decimal-pointcharacter appears only if it is followed by a digit.<dt><b>c</b><dd>The <b>int</b> argument is converted to an <b>unsigned char</b>, and the resulting character is written.<dt><b>s</b><dd>The argument should be a pointer to an array of character type.Characters from the array are written up to (but not including)a terminating null character; if the precision is specified,no more than that many characters are written. If the precisionis not specified or is greater than the size of the array, thearray will contain a null character.<dt><b>p</b><dd>The argument should be a pointer to <b>void</b>. The value of the pointer is converted to a sequence of printable characters,in hexadecimal representation (prefixed with "0x").<dt><b>n</b><dd>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -