Counting the out-of-order elements of an array
Avoid static variables as much as possible.
Instead of static total, you could pass in a pointer to total and make the function modify the value it's pointing to.

The names are not great:


Instead of my_array, start would be better
Instead of endp, end would be better
Instead of chck_high, ... I don't know what would be better, because I don't really see the general logic this function represents. It counts the number of times a new local maximum is found going backwards from the end of the range, and sets the value of total. I'm wondering if this logic is really necessary in this form, or perhaps the overall logic of your program could be redesigned to simpler elements.


Instead of a comment like this:


// this function should only be called if there is at least one value in the array



It would be better to use an assertion:

assert(start &lt; end);


Note that this requires to #include &lt;assert.h&gt;

This maybe a matter of taste, but I would find a for loop would be more natural for this instead of while. Using a for loop, in C99 and above, you could declare the loop variable inside the for, which would have extra benefits:


It would help you limit variables in the smallest scope necessary (inside the loop)
It would force you to use a new local variable for looping, instead of reusing the function parameter, which is a good thing


Putting it together, the function would become:

int chck_high(int *start, int *end, int *total) {
    assert(start &lt; end);

    int maximum = *--end;

    for (int * pos = end; pos &gt; start; --pos) {
        int a = *pos;
        if ( a &gt; maximum ) {
            ++*total;
            maximum = a;
        }
    }

    return maximum;
}


To enable C99 mode when compiling with gcc, use the -std=c99 flag.

You can use the function like this, for example:

int main() {
    int arr[] = {1, 2, 51, 41, 4, 5};
    int total = 1;
    int maximum = chck_high(&amp;arr[0], &amp;arr[0] + 6, &amp;total);
    printf("total=%d max=%d\n", total, maximum);
}