• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 870
  • Last Modified:

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,
skarve
0
skarve_Dev
Asked:
skarve_Dev
  • 2
3 Solutions
 
itsmeandnobodyelseCommented:
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.
0
 
itsmeandnobodyelseCommented:
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
0
 
Deepu AbrahamR & D Engineering ManagerCommented:
May be this will give you some more input:
http://www.cplusplus.com/ifstream
Best Regards,
DeepuAbrahamK
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now