setjump - C Libs | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

setjump - C Libs

Other than tutorials point and geeks for geeks websites does anyone have an example of using setjump and longjump, both site advocate the functions like a try-throw for C.

9th Apr 2022, 10:43 PM
William Owens
William Owens - avatar
3 Answers
+ 2
I cannot find my favorite example that I once saw on Sololearn, but here is a great one that is easy to understand. https://code.sololearn.com/ccg4HyQEWjLa/?ref=app
10th Apr 2022, 12:46 AM
Brian
Brian - avatar
0
Brian Thank you for that example. I do not see how that would be used like a try throw more like a conditional jmp in asm. Thank you for the assist. Always great help here.
10th Apr 2022, 11:59 AM
William Owens
William Owens - avatar
0
Yes, longjmp resembles a conditional jmp, but it effectively also cleans the stack, allowing you to bypass having to return all the way up the stack, and not requiring also every caller to recognize and deal with the exception before returning. There is a niche for its use, but I wince at the prospect of actually using it.
10th Apr 2022, 7:56 PM
Brian
Brian - avatar