DJGPP vs. VC++ 6.0

Posted on 2003-02-24
Medium Priority
Last Modified: 2010-04-01
I have the written the following code that works in the DJGPP compiler, but doesn't in the VC++ 6.0 compiler with service packs:

SightLine *allPoint = new SightLine;

while (!agIn.is_open())
     cout << "Please enter survey file: ";
     getline(cin, fName);

          if (fName.length() == 0 && EOF)
               throw 103;


          if (!agIn.is_open())
               throw 101;
     catch (int error)
          ret = errorHandler(error);

          if (ret == -1)
               delete allPoint;
               return 0;

agIn is an ifstream.  errorHandler and SightLine are included header files I've created.  The problem is when I run it to test a file that doesn't exist, it will throw the error.  Then I give it the correct file, and it doesn't read from it correctly.  It will open the file, but shows nothing in it.  It almost seems like the file doesn't stay open.  If I run it without entering the wrong file name first, it works, and if I run it either way in DJGPP it works.
Question by:CygnusKaltora
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

imadjinn earned 200 total points
ID: 8013076
It appears that in VC6 you have to clear the error flags using:


before you try to open a new file... add this to your catch block and your problem should be fixed.

Author Comment

ID: 8013185
Wow, that was fast.  Thank you.  VC++ seems to be really picky about how exactly you use its version of C++.  Fix worked perfectly.

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.
Suggested Courses

801 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