samedi 30 juin 2018

I got expected primary-expression before ')' token on my if-statement in the second function

The error occurs in both statements where it says string, but the same code works just fine in the first function above it! how do I make it stop?

void Store::FindBook(const char* string) const

{ if(ReportFind(string)<0) cout << "no books found" << endl;

   else
   {
       for(int i = 0; i < currentSize; i++)
       {
           if (strcmp(bookList[i].GetTitle(),string) == 0)
                   bookList[i].Display();
       }

       for(int i = 0; i < currentSize; i++)
       {
       if (strcmp(bookList[i].GetAuthor(),string) == 0)
                   bookList[i].Display();
       }
   }

======================================================================

int Store::ReportFind(const char*) const { for(int i = 0; i < currentSize; i++)

   {
   if (strcmp(bookList[i].GetTitle(),string) == 0)

           return i;
   }

for(int i = 0; i < currentSize; i++)
{
if(strcmp(bookList[i].GetAuthor(),string) == 0) return i;
}

return -1; }

Aucun commentaire:

Enregistrer un commentaire