Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

DJGPP vs. VC++ 6.0

Posted on 2003-02-24
2
Medium Priority
?
241 Views
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);

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

          agIn.open(fName.c_str());

          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.
0
Comment
Question by:CygnusKaltora
2 Comments
 
LVL 1

Accepted Solution

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

 agIn.clear();

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

Author Comment

by:CygnusKaltora
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.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 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.

571 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