Home

I need to write a function where the third parameter points to an
address whose dereferenced value equals one of the array element's
value, then the the function returns the index of the first matching
array element. Otherwise -1 is returned.
Here's what I have but I am going obviously wrong somewhere:

#include <iostream>
using namespace std;

// This function compares values
void indexvalue (int array [], int size, int *num)
{
for (int count = 0; count < size; count++)
{
if (*num = array [count])
cout << count << endl;
else {
cout << "-1" << endl;
}
}
}

int main ()
{
int four = 4;
int arr [6] = {1, 2, 3,4,5};
int size = 6;

indexvalue (arr, size, &four);

return 0;
}

previous
next

online doc bug
create Powerpoint via com
Re: Python Book Recommendations
Re: A malloc error in C++ - incorrect checksum for freed object
Re: startswith( prefix[, start[, end]]) Query
hi-fi
dekoracje okien
Urlop z dzieckiem
bižutérie
tusze do drukarek