简体   繁体   English

在C ++中从文件读取ASCII和二进制

[英]Read ASCII and binary from file in c++

我该如何打开文件并读取一些固定的ASCII代码行(假定为n),然后从C ++中的n + 1行开始切换到从同一文件读取BINARY?

You can't change the mode without reopening because the fstream uses system calls to open files which in turn do not allow a mode change. 您不能在不重新打开的情况下更改模式,因为fstream使用系统调用来打开文件,而这些文件又不允许更改模式。 You can use tellg / seekg to save and later restore the reading position, respectively. 您可以使用tellg / seekg分别保存和以后恢复读取位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM