zoukankan      html  css  js  c++  java
  • 无法打开包含文件:"fstream.h"

    刚刚在VS2010里面使用vc6.0的那种#include <fstream.h>方式,但是编译时提示fatal error C1083: 无法打开包括文件:“fstream.h”: No such file or directory。

    查阅了相关资料后,找到解决方法: 

    把  #include<fstream.h>改成  #include <fstream>    using namespace std; 

    编译、运行都顺利通过了~~~

    为什么会这样子呢?

    因为:

      从 Visual C++ .NET 2003 开始,移除了旧的 iostream 库.
      标准 C++ 库和以前的运行时库之间的主要差异在于 iostream 库。iostream 实现的 具体细节已经更改,如果想链接标准 C++ 库,可能有必要重写代码中使用                   iostream 的部分。
      必须移除任何包含在代码中的旧 iostream 头文件(fstream.h、iomanip.h、ios.h 、iostream.h、istream.h、ostream.h、streamb.h 和 strstrea.h)

      并添加一个 或多个新的标准 C++ iostream 头文件(<fstream>、<iomanip>、<ios>、<iosfwd> 、<iostream>、<istream>、<ostream>、         <sstream>、<streambuf> 和 <strstream> ,所有头文件都没有 .h 扩展名)。
    在新的标准 C++ iostream 库中:

      1. open 函数不采用第三个参数(保护参数)。

      2. 无法从文件句柄创建流。

      3. 除了几个例外,新的标准 C++ 库中的所有名称都在 std 命名空间中。有关更多信息,请参见使用 C++ 库头。

        4. 单独用 ios::out 标志无法打开 ofstream 对象。ios::out 标志必须在逻辑 OR 中和另一个 ios 枚举数组合;比如,和 ios::in 或 ios::app 组合。

      5. 因为设置了 eofbit 状态,到达文件尾后 ios::good 不再返回非零值。 除非知道当前没有设置基标志,否则 ios::setf(_IFlags)

        不应和 ios::dec、ios::oct 或 ios::hex 的标志值一起使用。格式化的输入/输出函数和运算符假定只设置了一个基。改用 ios_base。 

    更多改动的地方请查阅MSDN~

    除了上述改动外,以下作为旧 iostream 库元素的函数、常数和枚举数不是新 iostream 库的元素: filebuf、fstream ifstream 和 ofstream 的 attach 成员函数 filebuf、fstream ifstream 和 ofstream 的 fd 成员函数 filebuf::openprot filebuf::setmode ios::bitalloc ios::nocreate ios::noreplace ios::sync_with_stdio streambuf::out_waiting streambuf::setbuf(相同的行为使用 rdbuf -> pubsetbuf)

    转自:http://www.cnblogs.com/lingshaohu/archive/2011/11/07/2239453.html

  • 相关阅读:
    iOS 完美解决 interactivePopGestureRecognizer 卡住的问题
    Entity Framework 的事务 DbTransaction
    EntityClient 介绍
    ObjectQuery查询及方法
    Entity SQL 初入
    LINQ to Entities 查询注意事项
    IQueryable接口与IEnumberable区别
    CodeFirst 的编程方式
    Entity Framework 的小实例:在项目中添加一个实体类,并做插入操作
    实体框架(Entity Framework)简介
  • 原文地址:https://www.cnblogs.com/baoxiaofei/p/4266016.html
Copyright © 2011-2022 走看看