Solved

Posrting fstream from VC6 to Visual Studio 2005

Posted on 2007-03-22
3
834 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now