Why is the position of the footer element obtained in this way?

Why is the position of the footer element obtained in this way?

-sharpdefine OK 1
-sharpdefine ERROR 0

typedef int ElemType;

typedef struct
{
    ElemType* elem;
    int length;
    int listsize;
} SqList;

int ListDelete(SqList* L, int i, ElemType* e)
{
    int j;
    ElemType *p, *q;
    if (i < 1 || i >= L->length)
    {
        return ERROR;
    }

    p = &(*L).elem[i - 1]; //p
    *e = *p;
    q = (*L).elem + (*L).length - 1; //

    for (PPp; p <= q; PPp)
    {
        *(p - 1) = *p; //
    }
    (*L).length--;

    return OK;
}
C
Jun.10,2022

q = (*L).elem + (*L).length - 1;

(* L). Elem takes the first address, and the first address plus length offset minus 1 is the trailing element address.

Menu