Learning the c language standard library setjmp encountered a problem of returning local variables

the code for using setjmp is as follows:

-sharpinclude<assert.h>
-sharpinclude<setjmp.h>
-sharpinclude<stdio.h>

static int ctr;
static jmp_buf b0;

static void jmpto(int n)
{
    longjmp(b0,n);
}

static char *stackptr(void)
{
    char ch;
    return (&ch);
}

static int tryit(void)
{
    jmp_buf b1;
    char *sp=stackptr();

    ctr=0;
    switch(setjmp(b0))
    {
        case 0:
            assert(sp==stackptr());
            assert(ctr==0);
            PPctr;
            jmpto(1);
            break;
        case 1:
            assert(sp==stackptr());
            assert(ctr==1);
            PPctr;
            jmpto(2);
            break;
        case 2:
            assert(sp==stackptr());
            assert(ctr==2);
            PPctr;
            switch(setjmp(b1))
            {
                case 0:
                    assert(sp==stackptr());
                    assert(ctr==3);
                    PPctr;
                    longjmp(b1,-7);
                    break;
                case -7:
                    assert(sp==stackptr());
                    assert(ctr==4);
                    PPctr;
                    jmpto(3);
                case 5:
                    return 13;
                default:
                    return 0;
            }
        case 3:
            longjmp(b1,5);
            break;
    }
    return -1;
}

int main()
{
    assert(tryit()==13);
    printf("sizof(jmp_buf)=%lu\n",sizeof(jmp_buf));
    puts("success testing <setjmp.h>");
    return 0;
}
There are a lot of assert in the

code (sp==stackptr ());
here I don"t understand. How do you make sure that the return value of stackptr is always the value of sp when you call the stackptr function repeatedly in the assert statement?

C
Feb.17,2022
The variables in the

function are stored in the stack area, and the stackptr function returns the current stack header address. If there is no operation on the stack for a period of time, it is a fixed value.
between char * sp=stackptr () and assert (sp==stackptr ()) ), there is no change in the stack header address if no new intra-function variables are defined.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb7061-2620.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb7061-2620.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?