Solved

cpp works but exe not :-(

Posted on 2000-03-23
14
298 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
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 70 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

789 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