VS2005中有没有fstream.h头文件

zhou1xp 2010-02-26 04:57:48
新装的vs2005,在操作文件时竟然发现打不开fstream.h文件,请问各位,你们的vs2005中有这个文件么,我的vc6中是有的
...全文
556 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhou1xp 2010-02-28
  • 打赏
  • 举报
回复
呵呵,楼上所言是对的,看来要多熟悉下2005啊
密斯刘 2010-02-27
  • 打赏
  • 举报
回复
在VS2008下面找了一下,没有发现
帮你把6.0的贴上来了


/***
*fstream.h - definitions/declarations for filebuf and fstream classes
*
* Copyright (c) 1991-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file defines the classes, values, macros, and functions
* used by the filebuf and fstream classes.
* [AT&T C++]
*
* [Public]
*
****/

#if _MSC_VER > 1000
#pragma once
#endif

#ifdef __cplusplus

#ifndef _INC_FSTREAM
#define _INC_FSTREAM

#if !defined(_WIN32) && !defined(_MAC)
#error ERROR: Only Mac or Win32 targets supported!
#endif


#ifdef _MSC_VER
// Currently, all MS C compilers for Win32 platforms default to 8 byte
// alignment.
#pragma pack(push,8)

#include <useoldio.h>

#endif // _MSC_VER

/* Define _CRTIMP */

#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */


#include <iostream.h>

#ifdef _MSC_VER
// C4514: "unreferenced inline function has been removed"
#pragma warning(disable:4514) // disable C4514 warning
// #pragma warning(default:4514) // use this to reenable, if desired
#endif // _MSC_VER

typedef int filedesc;

class _CRTIMP filebuf : public streambuf {
public:
static const int openprot; // default share/prot mode for open

// optional share values for 3rd argument (prot) of open or constructor
static const int sh_none; // exclusive mode no sharing
static const int sh_read; // allow read sharing
static const int sh_write; // allow write sharing
// use (sh_read | sh_write) to allow both read and write sharing

// options for setmode member function
static const int binary;
static const int text;

filebuf();
filebuf(filedesc);
filebuf(filedesc, char *, int);
~filebuf();

filebuf* attach(filedesc);
filedesc fd() const { return (x_fd==-1) ? EOF : x_fd; }
int is_open() const { return (x_fd!=-1); }
filebuf* open(const char *, int, int = filebuf::openprot);
filebuf* close();
int setmode(int = filebuf::text);

virtual int overflow(int=EOF);
virtual int underflow();

virtual streambuf* setbuf(char *, int);
virtual streampos seekoff(streamoff, ios::seek_dir, int);
// virtual streampos seekpos(streampos, int);
virtual int sync();

private:
filedesc x_fd;
int x_fOpened;
};

class _CRTIMP ifstream : public istream {
public:
ifstream();
ifstream(const char *, int =ios::in, int = filebuf::openprot);
ifstream(filedesc);
ifstream(filedesc, char *, int);
~ifstream();

streambuf * setbuf(char *, int);
filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); }

void attach(filedesc);
filedesc fd() const { return rdbuf()->fd(); }

int is_open() const { return rdbuf()->is_open(); }
void open(const char *, int =ios::in, int = filebuf::openprot);
void close();
int setmode(int mode = filebuf::text) { return rdbuf()->setmode(mode); }
};

class _CRTIMP ofstream : public ostream {
public:
ofstream();
ofstream(const char *, int =ios::out, int = filebuf::openprot);
ofstream(filedesc);
ofstream(filedesc, char *, int);
~ofstream();

streambuf * setbuf(char *, int);
filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); }

void attach(filedesc);
filedesc fd() const { return rdbuf()->fd(); }

int is_open() const { return rdbuf()->is_open(); }
void open(const char *, int =ios::out, int = filebuf::openprot);
void close();
int setmode(int mode = filebuf::text) { return rdbuf()->setmode(mode); }
};

class _CRTIMP fstream : public iostream {
public:
fstream();
fstream(const char *, int, int = filebuf::openprot);
fstream(filedesc);
fstream(filedesc, char *, int);
~fstream();

streambuf * setbuf(char *, int);
filebuf* rdbuf() const { return (filebuf*) ostream::rdbuf(); }

void attach(filedesc);
filedesc fd() const { return rdbuf()->fd(); }

int is_open() const { return rdbuf()->is_open(); }
void open(const char *, int, int = filebuf::openprot);
void close();
int setmode(int mode = filebuf::text) { return rdbuf()->setmode(mode); }
};

// manipulators to dynamically change file access mode (filebufs only)
inline ios& binary(ios& _fstrm) \
{ ((filebuf*)_fstrm.rdbuf())->setmode(filebuf::binary); return _fstrm; }
inline ios& text(ios& _fstrm) \
{ ((filebuf*)_fstrm.rdbuf())->setmode(filebuf::text); return _fstrm; }

#ifdef _MSC_VER
#pragma pack(pop)
#endif // _MSC_VER

#endif // _INC_FSTREAM

#endif /* __cplusplus */

wutaihua 2010-02-27
  • 打赏
  • 举报
回复
很多头文件,比如 fstream.h中的.h不再存在了。.h后缀是旧iostream库的一部分,是不标准的。
(不过这样可以#include<fstream>);

zhou1xp 2010-02-27
  • 打赏
  • 举报
回复
顶一下>>>>>>>>>>>>.
jingzhongrong 2010-02-27
  • 打赏
  • 举报
回复
和iostream.h一样,去掉.h,并加上名字空间的引用。
zhou1xp 2010-02-26
  • 打赏
  • 举报
回复
那2005中如何使用getline函数呢,我以前一直是用ofstream类来操作的
fengrx 2010-02-26
  • 打赏
  • 举报
回复
没有 。

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧