📄 open.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org"> <title>open</title> <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table> <tr> <td> <div class="body-content"> <div class="header-box"> <a href="../index.html">cppreference.com</a> > <a href= "index.html">C++ I/O</a> > <a href="open.html">open</a> </div> <div class="name-format"> open </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <fstream> void open( const char *filename ); void open( const char *filename, openmode mode = default_mode );</pre> <p>The function open() is used with file streams. It opens <em>filename</em> and associates it with the current stream. The optional <a href="../io_flags.html#mode_flags">io stream mode flag</a> <em>mode</em> defaults to ios::in for ifstream, ios::out for ofstream, and ios::in|ios::out for fstream.</p> <p>If open() fails, the resulting stream will evaluate to false when used in a Boolean expression. For example:</p> <pre class="example-code"> ifstream inputStream; inputStream.open("file.txt"); if( !inputStream ) { cerr << "Error opening input stream" << endl; return; } </pre> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="constructors.html">I/O Constructors</a><br> <a href="close.html">close</a> </div> </div> </td> </tr> </table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -