📄 all.html
字号:
<div class="name-format"> putback </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> istream& putback( char ch );</pre> <p>The putback() function is used with input streams, and returns the previously-read character <em>ch</em> to the input stream.</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="peek.html">peek</a><br> (Standard C I/O) <a href="../stdio/ungetc.html">ungetc</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> rdstate </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> iostate rdstate();</pre> <p>The rdstate() function returns the <a href= "../io_flags.html#state_flags">io stream state flag</a>s of the current stream.</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="bad.html">bad</a><br> <a href="clear.html">clear</a><br> <a href="eof.html">eof</a><br> <a href="fail.html">fail</a><br> <a href="good.html">good</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> read </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> istream& read( char* buffer, streamsize num );</pre> <p>The function read() is used with input streams, and reads <em>num</em> bytes from the stream before placing them in <em>buffer</em>. If <strong>EOF</strong> is encountered, read() stops, leaving however many bytes it put into <em>buffer</em> as they are.</p> <p>For example:</p> <pre class="example-code"> struct { int height; int width; } rectangle; input_file.read( (char *)(&rectangle), sizeof(rectangle) ); if( input_file.bad() ) { cerr << "Error reading data" << endl; exit( 0 ); } </pre> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="gcount.html">gcount</a><br> <a href="get.html">get</a><br> <a href="getline.html">getline</a><br> <a href="write.html">write</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> seekg </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> istream& seekg( off_type offset, ios::seekdir origin ); istream& seekg( pos_type position );</pre> <p>The function seekg() is used with input streams, and it repositions the "get" pointer for the current stream to <em>offset</em> bytes away from <em>origin</em>, or places the "get" pointer at <em>position</em>.</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="seekp.html">seekp</a><br> <a href="tellg.html">tellg</a><br> <a href="tellp.html">tellp</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> seekp </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> ostream& seekp( off_type offset, ios::seekdir origin ); ostream& seekp( pos_type position );</pre> <p>The seekp() function is used with output streams, but is otherwise very similar to <a href="seekg.html">seekg</a>().</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="seekg.html">seekg</a><br> <a href="tellg.html">tellg</a><br> <a href="tellp.html">tellp</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> setf </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> fmtflags setf( fmtflags flags ); fmtflags setf( fmtflags flags, fmtflags needed );</pre> <p>The function setf() sets the <a href= "../io_flags.html#format_flags">io stream format flag</a>s of the current stream to <em>flags</em>. The optional <em>needed</em> argument specifies that only the flags that are in both <em>flags</em> and <em>needed</em> should be set. The return value is the previous configuration of <a href= "../io_flags.html#format_flags">io stream format flag</a>s.</p> <p>For example:</p> <pre class="example-code"> int number = 0x3FF; cout.setf( ios::dec ); cout << "Decimal: " << number << endl; cout.unsetf( ios::dec ); cout.setf( ios::hex ); cout << "Hexadecimal: " << number << endl; </pre> <p>Note that the preceding code is functionally identical to:</p> <pre class="example-code"> int number = 0x3FF; cout << "Decimal: " << number << endl << hex << "Hexadecimal: " << number << dec << endl; </pre> <p>thanks to <a href="../io_flags.html#manipulators">io stream manipulator</a>s.</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="flags.html">flags</a><br> <a href="unsetf.html">unsetf</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> sync_with_stdio </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> static bool sync_with_stdio( bool sync=true );</pre> <p>The sync_with_stdio() function allows you to turn on and off the ability for the C++ I/O system to work with the C I/O system.</p> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> tellg </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> pos_type tellg();</pre> <p>The tellg() function is used with input streams, and returns the current "get" position of the pointer in the stream.</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="seekg.html">seekg</a><br> <a href="seekp.html">seekp</a><br> <a href="tellp.html">tellp</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> tellp </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> pos_type tellp();</pre> <p>The tellp() function is used with output streams, and returns the current "put" position of the pointer in the stream.</p> <p>For example, the following code displays the file pointer as it writes to a stream:</p> <pre class="example-code"> string s("In Xanadu did Kubla Khan..."); ofstream fout("output.txt"); for( int i=0; i < s.length(); i++ ) { cout << "File pointer: " << fout.tellp(); fout.put( s[i] ); cout << " " << s[i] << endl; } fout.close(); </pre> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="seekg.html">seekg</a><br> <a href="seekp.html">seekp</a><br> <a href="tellg.html">tellg</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> unsetf </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> void unsetf( fmtflags flags );</pre> <p>The function unsetf() uses <em>flags</em> to clear the <a href= "../io_flags.html#format_flags">io stream format flag</a>s associated with the current stream.</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="flags.html">flags</a><br> <a href="setf.html">setf</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> width </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> int width(); int width( int w );</pre> <p>The function width() returns the current width, which is defined as the minimum number of characters to display with each output. The optional argument <em>w</em> can be used to set the width.</p> <p>For example:</p> <pre class="example-code"> cout.width( 5 ); cout << "2"; </pre> <p>displays</p> <pre class="example-code"> 2 </pre> <p>(that's four spaces followed by a '2')</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="fill.html">fill</a><br> <a href="precision.html">precision</a> </div> </div> </td> </tr> </table></body></html><hr> <div class="name-format"> write </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> ostream& write( const char* buffer, streamsize num );</pre> <p>The write() function is used with output streams, and writes <em>num</em> bytes from <em>buffer</em> to the current output stream.</p> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="flush.html">flush</a><br> <a href="put.html">put</a><br> <a href="read.html">read</a> </div> </div> </td> </tr> </table></body></html><hr></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -