Solved

Posrting fstream from VC6 to Visual Studio 2005

Posted on 2007-03-22
3
843 Views
Last Modified: 2013-11-27
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
Comment
Question by:skarve_Dev
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 480 total points
ID: 18769630
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
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 480 total points
ID: 18769639
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
 
LVL 11

Assisted Solution

by:DeepuAbrahamK
DeepuAbrahamK earned 20 total points
ID: 18770155
May be this will give you some more input:
http://www.cplusplus.com/ifstream
Best Regards,
DeepuAbrahamK
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to file 3 92
Need more details 5 184
Authentication of Web Services 3 96
find Speed using GPS latitude & longitude 4 90
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question