
June 25th, 2004, 09:37 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Location: manhattan
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
simple C++ question about searching an array
I have a problem am a beginer at c++, am trying to lenear search my array in a function, the search always gives me the same result i wonder if am doing anything.
int searchid(float arr[], int n,int check)
{
for(int i = 0; i < n; i++)
if (arr[i] == check) return i;
return -1;
}
this is my function is passing a one dimensional array, its lenght as n, and a value which is the number (check) am trying to find within the array. any help would be greatly appresiated.
|