hey guys, this is what i have so far...
this part is from the main.cpp
double x;
cout<<"Enter a number to search for: \n";
cin>>x;
list.search(x);
if (list.search(x))
cout << "\n" << x << " IS on the list! AT POSITION :" <<endl;
else
cout << "\n" << x << " IS NOT on the list." << endl;
and this part is from the .h header
int floatlist::search(double x)
{
listnode *p = head;
while (p != NULL)
{
if (p->value == x)
return 1;
else
p = p->next;
}
return 0;
so far it works, im able to enter some numbers and have the search function tell if the number is in the list or not. the only thing i cant figure out is how to say where the position of the number being found is.
i was thinking of putting a counter++; in the while(p != NULL) part, so everytime it goes through the numbers, it counts. and then return the counter value. i couldnt get that to work though.
any help would be appreciated.
-j