Solved

cpp works but exe not :-(

Posted on 2000-03-23
14
297 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 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 learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now