]>
Commit | Line | Data |
---|---|---|
53668523 L |
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
2 | <html lang="en"> | |
3 | <head> | |
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> | |
10 | </head> | |
11 | ||
12 | <body> | |
13 | ||
14 | <div class="para func"> | |
15 | <h2>f_printf</h2> | |
16 | <p>The f_printf function writes formatted string to the file.</p> | |
17 | <pre> | |
18 | int f_printf ( | |
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> | |
21 | ... | |
22 | ); | |
23 | </pre> | |
24 | </div> | |
25 | ||
26 | <div class="para arg"> | |
27 | <h4>Parameters</h4> | |
28 | <dl class="par"> | |
29 | <dt>fp</dt> | |
30 | <dd>Pointer to the open file object structure.</dd> | |
31 | <dt>fmt</dt> | |
32 | <dd>Pointer to the null terminated format string. The terminator charactor will not be written.</dd> | |
33 | <dt>...</dt> | |
34 | <dd>Optional arguments...</dd> | |
35 | ||
36 | </dl> | |
37 | </div> | |
38 | ||
39 | ||
40 | <div class="para ret"> | |
41 | <h4>Return Values</h4> | |
70702af1 | 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> |
53668523 L |
43 | </div> |
44 | ||
45 | ||
46 | <div class="para desc"> | |
47 | <h4>Description</h4> | |
70702af1 | 48 | <p>The format control directive is a sub-set of standard library shown as follos:</p> |
53668523 L |
49 | <ul> |
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> | |
53 | </ul> | |
54 | </div> | |
55 | ||
56 | ||
57 | <div class="para comp"> | |
58 | <h4>QuickInfo</h4> | |
70702af1 L |
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> | |
53668523 L |
61 | </div> |
62 | ||
63 | ||
64 | <div class="para use"> | |
65 | <h4>Example</h4> | |
66 | <pre> | |
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> | |
82 | </pre> | |
83 | </div> | |
84 | ||
85 | ||
86 | <div class="para ref"> | |
87 | <h4>See Also</h4> | |
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> | |
89 | </div> | |
90 | ||
91 | <p class="foot"><a href="../00index_e.html">Return</a></p> | |
92 | </body> | |
93 | </html> |