Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fstream and ostrstream is undefined

Tags:

visual-c++

HI,

I am converting my project from vc6 to latest using vs 2010. I get problem on compiling my code

Error 931 error C2065: 'ostrstream' : undeclared identifier 1100 IntelliSense: identifier "fstream" is undefined

I have included the required files as told in Google

#if ! defined(_FSTREAM_)
    #include <fstream> 
#endif 

#if ! defined(_STRSTREAM_)      
   #include <strstream>      
#endif 

When i press F12 on the fstream or ostrstream it takes to the respective files where these class are defined. Is there any other includes i have to do, i have been searching for this for long time with no luck :(

Thanks

Arvind

like image 529
Arvind Avatar asked Feb 03 '26 14:02

Arvind


2 Answers

Add these to your library list:

#include <stdio.h>

using namespace std;
like image 64
Dana Avatar answered Feb 05 '26 08:02

Dana


Forget all the preprocessor stuff; it's redundant at best (the files in questiion will have reinclusion guards) and at worst an error (you're assuming the #defines used, which are arbitary). Just use code like this:

#include <fstream>
#include <strstream>

Also note that the strstream header is deprecated. You should use sstream instead, but note the newer classed in this file word differently to the deprecated ones).

like image 21
Steve Avatar answered Feb 05 '26 08:02

Steve



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!