Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Return to start function?

Posted on 2001-06-21
4
Medium Priority
?
192 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

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.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

618 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