the problem its simple i don`t know whats wrong with my array i spell it correctly and it does not apear in my binary function... can someone help me plz thx in advance
int binsearch(int data[], int numElements, int searchkey /* int searchkey */)
{
int resultado=0, mitad = 11,g=0,searchkey=0; // ERROR: searchkey already exists
// BUT
// int resultado=0, mitad = 11, g = 0; // OK
// searchkey = 0; // OK
}
int binsearch(int data[], int numElements, int searchkey) // interger variable called searchkey
{
int resultado=0, mitad = 11,g=0,searchkey=0; //Error - already have a variable in this function called searchkey - see above
while(data[resultado]==searchkey)
{
g=mitad;
if(searchkey==data[mitad])
{
......
that was a mistake that i did while copy and fixing at the same time but the array issue still persist the array when i test it in the other fuction apears empty with only a single variable thx for the help that you can bring to me
oh god!! i found it XD thx body i love you too... anyway the mistake was at the while. The array was correctly passed by the fuction but the while interfere because i had to put != rather than ==. And with some minor fixes in the function now everything was going well. thx for the help you lend me.
while(data[resultado]==searchkey) // its != not == XD