在Visual C ++中创建文本文件
问题描述:
如何创建,读取和写入文本文件
how do you create, read and write to a text file
答
例如使用<fstream>
标头提供的流类,例如任何C++
书籍(甚至是不良书籍).此处的示例[ ^ ].
:)
For instance using the stream classes provided by<fstream>
header, as you may find in anyC++
book (even bad ones). Examples here [^].
:)
请注意,fstream是C ++,而FileOpen等方法是C,如果可以避免,则不应在C ++中使用.
而且,当然,核心问题是您需要购买一本基本的C ++书籍并阅读.
Just to note, fstream is C++, and the FileOpen, etc. methods are C and should NOT be used in C++ if you can at all avoid it.
And, of course, the core issue is that you need to buy a basic C++ book and read it.
可以使用CreateFile,ReadFile和WriteFile.
CreateFile, ReadFile, WriteFile can be used.