Posrting fstream from VC6 to Visual Studio 2005

Hi, I am trying to compile a working C++ file under Visual Studio 2005 (With SP1). It was earlier complaining about fstream.h. So I changed it to include <fstream> instead of the fstream.h. Now it gives me hundreds of errors like "Error      1      error C2146: syntax error : missing ';' before identifier 'source' etc  at the line where I have declared ifstream and ofstream.

Any help is appreciated

Thanks you,
Who is Participating?
itsmeandnobodyelseConnect With a Mentor Commented:
You should add

using namespace std;

below your include statement in the cpp. In the header files add prefix std:: to any occurence of ifstream and ofstream.
itsmeandnobodyelseConnect With a Mentor Commented:
Note if changing to <fstream> you need to change to <iostream>, <iomanip>, <sstream> as well. Here applies the same regarding the std:: prefix. Note the string stream classes have changed to istringstream and ostringstream. They are based on std::string == std::basic_string<char>, so you most likely have to relace <string.h> by <string> as well what is recommended anyway but may cause some more porting issues.

Regards, Alex
Deepu AbrahamConnect With a Mentor R & D Engineering ManagerCommented:
May be this will give you some more input:
Best Regards,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.