1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-1">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
6 <link rel=
"up" title=
"FatFs" href=
"../00index_e.html">
7 <link rel=
"alternate" hreflang=
"ja" title=
"Japanese" href=
"../ja/printf.html">
8 <link rel=
"stylesheet" href=
"../css_e.css" type=
"text/css" media=
"screen" title=
"ELM Default">
9 <title>FatFs - f_printf
</title>
14 <div class=
"para func">
16 <p>The f_printf function writes formatted string to the file.
</p>
19 FIL*
<span class=
"arg">fp
</span>,
<span class=
"c">/* [IN] File object */
</span>
20 const TCHAR*
<span class=
"arg">fmt
</span>,
<span class=
"c">/* [IN] Format stirng */
</span>
26 <div class=
"para arg">
30 <dd>Pointer to the open file object structure.
</dd>
32 <dd>Pointer to the null terminated format string. The terminator charactor will not be written.
</dd>
34 <dd>Optional arguments...
</dd>
40 <div class=
"para ret">
41 <h4>Return Values
</h4>
42 <p>When the function succeeded, it returns number of characters written. If the function could not write the generated string to the file due to disk full or an error,
<tt>EOF (-
1)
</tt> will be returned.
</p>
46 <div class=
"para desc">
48 <p>The format control directive is a sub-set of standard library shown as follos:
</p>
50 <li>Type:
<tt>c C s S d D u U x X b B
</tt></li>
51 <li>Size:
<tt>l L
</tt></li>
52 <li>Flag:
<tt>0 -
</tt></li>
57 <div class=
"para comp">
59 <p>This is a wrapper function of
<a href=
"write.html"><tt>f_write
</tt></a> function. Available when
<tt>_FS_READONLY ==
0</tt> and
<tt>_USE_STRFUNC
</tt> is
1 or
2. When it is set to
2,
<tt>'\n'
</tt>s contained in the output are converted to
<tt>'\r'+'\n'
</tt>.
</p>
60 <p>When FatFs is configured to Unicode API (
<tt>_LFN_UNICODE ==
1</tt>), data types on the srting fuctions,
<tt>f_putc
</tt>,
<tt>f_puts
</tt>,
<tt>f_printf
</tt> and
<tt>f_gets
</tt> function, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by
<tt>_STRF_ENCODE
</tt> option.
</p>
64 <div class=
"para use">
67 f_printf(
&fil,
"%d",
1234);
<span class=
"c">/*
"1234" */
</span>
68 f_printf(
&fil,
"%6d,%3d%%", -
200,
5);
<span class=
"c">/*
" -200, 5%" */
</span>
69 f_printf(
&fil,
"%ld",
12345L);
<span class=
"c">/*
"12345" */
</span>
70 f_printf(
&fil,
"%06d",
25);
<span class=
"c">/*
"000025" */
</span>
71 f_printf(
&fil,
"%06d", -
25);
<span class=
"c">/*
"000-25" */
</span>
72 f_printf(
&fil,
"%-6d",
25);
<span class=
"c">/*
"25 " */
</span>
73 f_printf(
&fil,
"%u", -
1);
<span class=
"c">/*
"65535" or
"4294967295" */
</span>
74 f_printf(
&fil,
"%04x",
0xAB3);
<span class=
"c">/*
"0ab3" */
</span>
75 f_printf(
&fil,
"%08LX",
0x123ABCL);
<span class=
"c">/*
"00123ABC" */
</span>
76 f_printf(
&fil,
"%016b",
0x550F);
<span class=
"c">/*
"0101010100001111" */
</span>
77 f_printf(
&fil,
"%s",
"String");
<span class=
"c">/*
"String" */
</span>
78 f_printf(
&fil,
"%8s",
"abc");
<span class=
"c">/*
" abc" */
</span>
79 f_printf(
&fil,
"%-8s",
"abc");
<span class=
"c">/*
"abc " */
</span>
80 f_printf(
&fil,
"%c", 'a');
<span class=
"c">/*
"a" */
</span>
81 f_printf(
&fil,
"%f",
10.0);
<span class=
"c">/* f_printf lacks floating point support */
</span>
86 <div class=
"para ref">
88 <p><tt><a href=
"open.html">f_open
</a>,
<a href=
"putc.html">f_putc
</a>,
<a href=
"puts.html">f_puts
</a>,
<a href=
"gets.html">f_gets
</a>,
<a href=
"close.html">f_close
</a>,
<a href=
"sfile.html">FIL
</a></tt></p>
91 <p class=
"foot"><a href=
"../00index_e.html">Return
</a></p>