Link to home
Start Free TrialLog in
Avatar of CygnusKaltora
CygnusKaltora

asked on

DJGPP vs. VC++ 6.0

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.
ASKER CERTIFIED SOLUTION
Avatar of imadjinn
imadjinn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CygnusKaltora
CygnusKaltora

ASKER

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