?
Solved

cpp works but exe not :-(

Posted on 2000-03-23
14
Medium Priority
?
305 Views
Last Modified: 2010-04-02
Hi,

I run a cpp file in the Borland C++5.02 edit window, it looks fine.
Immediately after that I run the created exe file and got error message:
"This program has performed an illegal operation and will be shut down."

This is my old problem...just don't know what to do.

Do you think I should send the code to you for check? Or any suggestion?    
0
Comment
Question by:victorlong
[X]
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
14 Comments
 
LVL 5

Expert Comment

by:pitonyak
ID: 2651510

1) Post the code

2) Check for uninitialized variables. I recently had this problem and it was random based upon what just happened to be in memory when it was created. In the debugger the RAM just happened to be set to zero.

3) Use a binary search and start commenting out code until you have a small program which fails.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2651770
Run the program under a debugger and see where it is crashing.

Most likely you are usng an invalid pointer.
0
 

Author Comment

by:victorlong
ID: 2652957
To pitonyak :

Thank you.

Yes, The program have been reduced but still too big to be posted.......

--------------------------------------------------------

To nietod :

Thank you.

I need to find a debugger? Where?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:amador
ID: 2653017
you can use Visual C++ to debug, is the better.

Do you have it?
0
 
LVL 22

Expert Comment

by:nietod
ID: 2653056
Yes, VC's debugger is far far beter than Borland's.  But since victorlong is using using Borland 5, he probably doesn't have VC....

Borland 5 comes with a debugger.  There should be a menu option to run the program under the debugger.  (Its been 4 years since I've seen Borland 5 so I don't know what it is called.)

However, you should strongly consider buying an up-to-date compiler.  BC 5 is very very very out-of-date.  I would recommmend VC 6 or Borland Builder 5. (VC usually over builder).  Both will have far superior debugggers and numerious other improvements too.
0
 

Author Comment

by:victorlong
ID: 2653190
To pitonyak :

Thank you.

Yes, The program have been reduced but still too big to be posted.......

--------------------------------------------------------

To nietod :

Thank you.

I need to find a debugger? Where?
0
 

Author Comment

by:victorlong
ID: 2653266
To amador:

No, I haven't got  VC :-)

To nietod:

Do I need one month to lean VC?

I did further test, the error seems not stay at one place! I commented out paragragh A, the error dissapeared when run the exe. Next time I restore paragragh A but commented out paragragh B, the error can also dissapeared.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2653274
The debugger is part of BC 5.   You already have it.   Look under the menus.
0
 

Author Comment

by:victorlong
ID: 2653522
To nietod :

Yes, I know that one and think that is difficult for me to use.....I hope we can set some feature to a compiler so that the errors may be chatched and display messages domething like "divide by zero", "out of bound" or "invalid pointer"....
0
 
LVL 22

Expert Comment

by:nietod
ID: 2653543
It is not hard to learn VC and well worth it.  it has fantastic on-line help, which is the main reason I usually recommend it over BC and BCB.   There are also several good books available for learning VC itself.

The behavior you describe is common when you are using uniitialized pointers.  As you add/remove stuff in each version the damage done by the pointer moves around and causes different problems.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2653556
There is no option to print messages like that.  You must use a debugger.  One comes with BC!  There will be a debug option in the menus.  
0
 
LVL 2

Accepted Solution

by:
abesoft earned 280 total points
ID: 2653708
Borland's debugger (Turbo Debugger) is called TD (DOS version), TD386 (extended DOS version, I think), or TDW (Windows version).  All are .exe's.  So, if your app is a Windows app, you could use Window's "File Find" command to look for TDW.EXE, and then run that.  

From the debugger, you can load up your app and run it.

Good luck.
0
 

Author Comment

by:victorlong
ID: 2654867
Hi abesoft,

Your information is great:

1. when try the TDs I found Borland c++5.02 is only a dos version!!
2. I catch the bug in my program: divide by zero again!!!

That bug stop running the exe but not the cpp.

I need to test further....
0
 

Author Comment

by:victorlong
ID: 2655373
To  nietod:

Thank you so much for your help. Perhaps, I will try to learn VC one day :-)

I will give the points to abesoft who's suggestion directly leads the solusion of the question.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

777 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