Anyone know why my find method is returning false all the time?

When I try to get true by inputting the correct isbn, it still returns false. Any Ideas?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  bool Warehouse:: find (string isbn, Book& book) const{
    bool result = false;
    for (int i=0;i<bookCount;i++){
        if(isbn==books[i].getIsbn()){
            book = books[i];
            cout << "ISBN: " << isbn << "-- FOUND"<<endl;
            cout << books[i] << endl;
            result = true;
        }
        else {
            cout << "ISBN: " << isbn << "NOT FOUND" << endl;
        }
    }   
    return result;
}


This is my Book.cpp (where it holds the getISBN method)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
}
void Book::setTitle(string title){
    this->title_=title;
}
string Book::getTitle()const{
    return title_;
}

void Book:: setIsbn(string isbn){
    isbn_ = isbn;
}
string Book::getIsbn()const {
    return isbn_;
}


when I print out the isbn for each book, the isbn are there, but I do not know why it doesn't match with the isbn I put into the parameter.
Use a debugger, or add some debug printing of your own.
1
2
3
4
5
    for (int i=0;i<bookCount;i++){
        string bookIsbn = books[i].getIsbn();
        cout << "A=" << isbn << "=\n";
        cout << "B=" << bookIsbn << "=\n";
        if(isbn==bookIsbn){


If you don't see exactly this, you know you messed up somewhere

A=0-201-60464-7=
B=0-201-60464-7=


Say for example, something like this, which would indicate your input isbn has a trailing newline.

A=0-201-60464-7
=
B=0-201-60464-7=

Topic archived. No new replies allowed.