Solved

cpp works but exe not :-(

Posted on 2000-03-23
14
301 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ question 3 81
c++ reading data from file into two dimensional array 3 146
Precision Problem in C++ 7 67
why doesn't assert terminate here? 2 18
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

739 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