Click here to Skip to main content
15,905,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Let suppose there is a function a() which will call function b() and b() will call c() now for some reason I want to return from c() to a() without going via b().

void c()
{
   /* want to return to a() from here without going via b() */
}

void b()
{
    c();
}

void a()
{
    b();
}


How can we do it in c.

Can we do something like passing the address one word after the place b() is called and go to the address but in this case we have not returned from c().

Could you please answer this.

Thanks
vikas
Posted
Updated 6-Sep-10 21:27pm
v2
Comments
Dalek Dave 7-Sep-10 3:27am    
Edited for Grammar and Code Block.

1 solution

setjmp and longjmp will do the sort of thing you want to do. However it's probably better to restructure your code to return normally using a return code than non-local jumping.

Don't do something mad like trying to manually jump somewhere as it'll probably end in tears with a screwed stack (unless you really know what you're doing in which case you wouldn't be asking the question).

Cheers,

Ash
 
Share this answer
 
Comments
vikasvds 7-Sep-10 5:53am    
Reason for my vote of 5
good explaination

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900