hello everyone,

I found that gcc version 9.2.1 20191008,

i to compiles a binary search algorithm program that I write that only checks the function prototype,

but does not check the name after the definition?

/ * binary bearch * /
#include <stdio.h>
int bsearch(int x, int a[], int n);
int main(void)
{
    int a[] = {
        0, 555,
        3, 4, 5,
        6,
    };
    printf("%d\n", bsearch(0, a, sizeof a / sizeof a[0]));
    return 0;
}


int abaaaaasjkjjjjjjjjjjjjjkjjjjjjjjjjjjjjjjjjjjjjjjjjjjerch(int x, int a[], int n)
{
    int low;
    int hig;
    int mid;

    low = 0;
    hig = n - 1;
    while (low <= hig) {
        mid = (low + hig) / 2;
        if (x < *(a + mid))
            hig = mid - 1;
        else if (x > *(a + mid))
            low = mid + 1;
        else
            return mid;
    }
    return -1;
}


Reply via email to