|
-
August 5th, 2005, 02:30 AM
#1
fstream : sh_write is not a member of 'std::basic_filebuf<_Elem,_Traits>'
Hi
I am using fstream class for file I/O operations. When I upgrade my compiler to VC++ 7.1 from VC 6.0 I get compilation error on fstream related operation.
With 6.0 I was using include fstream.h, while with VC++ 7.1 I am using fstream as fstream.h is no longer supported with 7.1.
Sample Code:
filebuf *pFb = Fb.open ("abc", ios: ut, filebuf::sh_write);
Error:
sh_write is not a member of 'std::basic_filebuf<_Elem,_Traits>'
Regards
Devendra
-
August 5th, 2005, 03:14 AM
#2
Re: fstream : sh_write is not a member of 'std::basic_filebuf<_Elem,_Traits>'
MSDN said
Code:
basic_filebuf *open(
const char *_Filename,
ios_base::openmode _Mode
);
where the 3rd param?
-
August 5th, 2005, 03:19 AM
#3
Re: fstream : sh_write is not a member of 'std::basic_filebuf<_Elem,_Traits>'
fstream is part of the STL library and is not the same as that used by fstream.h.
What you probably need is...
Code:
filebuf *pFb = Fb.open("abc", ios_base::out);
From MSDN...
ios_base: penmode
typedef T3 openmode; static const openmode app, ate, binary, in, out, trunc; The type is an enumerated type T3 that describes an object that can store the opening mode for several iostreams objects. The distinct flag values are:
- app, to seek to the end of a stream before each insertion
- ate, to seek to the end of a stream when its controlling object is first created
- binary, to read a file as a binary stream, rather than as a text stream
- in, to permit extraction from a stream
- out, to permit insertion to a stream
- trunc, to truncate an existing file when its controlling object is first created
-
August 7th, 2005, 07:33 AM
#4
Re: fstream : sh_write is not a member of 'std::basic_filebuf<_Elem,_Traits>'
Thanks John.
So with fstream the open function have 2 parameters only.
But what is the alternate of sh_write/sh_read in fstream now ??
Regards
Devendra
-
August 7th, 2005, 07:42 AM
#5
Re: fstream : sh_write is not a member of 'std::basic_filebuf<_Elem,_Traits>'
 Originally Posted by devendraC
But what is the alternate of sh_write/sh_read in fstream now ??
To write to a file use an ofstream to read use an ifstream.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|