2
votes

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

3

3 Answers

4
votes

Add these to your library list:

#include <stdio.h>

using namespace std;
1
votes

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).

0
votes

What worked for me was a combination of two answer. After some trial and error, fstream squiggly red lines vanished when I added,

#include <fstream>
using namespace std;