日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

一个函数里两个setjmp_C语言中setjmp.h的longjmp()函数

發布時間:2025/3/11 编程问答 13 豆豆
生活随笔 收集整理的這篇文章主要介紹了 一个函数里两个setjmp_C语言中setjmp.h的longjmp()函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一個函數里兩個setjmp

We can call this function as an advance version of goto statement but with more dynamic range. The longjump() function allows us to pass parameters to know that the control has been jumped or not.

我們可以將此函數稱為goto語句的高級版本,但具有更大的動態范圍。 longjump()函數使我們可以傳遞參數來知道控件是否已跳轉。

So how to use this is the question. First thing is to decide point from where you want to jump and then decide to where you want to jump.

因此,如何使用此問題。 第一件事是確定要從哪里跳轉的點,然后再確定要跳轉的位置。

Before setting these point just make a jum_buf object. Now rest is a cake walk. In this example, I have put the point from where we want to jump inside a function called func by calling the function longjmp(a, 1) with two parameters as the jum_buf object and 1 will be return at the setjump call.

在設置這些點之前,只需創建一個jum_buf對象。 現在休息是輕輕松松。 在此示例中,我通過調用帶有兩個參數的longjmp(a,1)函數作為jum_buf對象,將要從其中跳轉到函數func的位置,在setjump調用中將返回1。

Call the function setjmp() at the point to where you want to jump. The Second parameter from the longjump will be stored in z. This z can be then checked for loops or maybe something else.

在要跳轉的位置調用函數setjmp() 。 longjump中的第二個參數將存儲在z中 。 然后可以檢查此z的循環或其他內容。

setjmp.h- longjmp()函數在C中的示例 (setjmp.h- longjmp() function Example in C)

</ s> </ s> </ s> #include <stdio.h> #include <setjmp.h>//defining the type of the variable static jmp_buf a;void func(void) {//message for userprintf("Function starts here..\n");//calling functionlongjmp(a, 1);//message for userprintf("Function ends here..\n"); }int main() {int z;//message for userprintf("Main starts here..\n");//setting current value in zz = setjmp(a);//condition to display messageif (z != 0){//message for userprintf("longjmp function called\n");return 0;}func();//message for userprintf("Main ends here..\n");return 0; }

Output

輸出量

翻譯自: https://www.includehelp.com/c-programs/longjmp-function-of-setjmp-h-in-c.aspx

一個函數里兩個setjmp

總結

以上是生活随笔為你收集整理的一个函数里两个setjmp_C语言中setjmp.h的longjmp()函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。