?
Solved

Return to start function?

Posted on 2001-06-21
4
Medium Priority
?
185 Views
Last Modified: 2013-11-20
Hi experts,

I call function A(), A() calls B(),...., calls Z().
If something wrong in function Z(), program will be stoped by exit(0) in the function Z().
Now, I want it goes back to function A(), instead of stoped, if anything wrong in function Z().
I know we can do that by 'return' from z() to Y()....to A() but need hard work!

Any good suggestions?
0
Comment
Question by:learn
[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
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
migel earned 240 total points
ID: 6214017
Hi!
use exception mechanism
that is:
A()
{
try
{
B();
}
catch(int)
{
// something wrong in the call chain
}
}

B()
{
Z();
}

Z()
{
if (error condition)
 throw 5; // generate exception;
}
0
 
LVL 3

Expert Comment

by:cypherljk
ID: 6214019
learn,
  I don't know what you mean by 'something goes wrong' but take a look at using 'try' and 'catch' blocks.  If an error or exception is caught it will be passed back up the calling stack.  the calling stack is a list of the functions that are currently executing. For example if A(), A() calls B(),...., calls Z() and exception 1 happens in z() if your catch block in in z catchs errors/exceptions of type 1 you could call a() from there OR you could have the catch in a(). You'll need to look up exceptions handling as there are many ways you can handle and pass exceptions and errors.

My 2 cents...
0
 

Author Comment

by:learn
ID: 6214640
Thanks a lot, that works great.

Thanks to all experts as well.....
0
 
LVL 3

Expert Comment

by:cypherljk
ID: 6216884
close the reference to this ? in the c++ section

my 2 cents...
0

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

741 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