Menu

Would Someone Able Break C Code Line Line Tell Line Means Void Printbooksbyauthor Std Stri Q43794685

Would someone be able to break this C++ code down line by lineand tell me what each line means?

void printBooksByAuthor(std::string titles[], std::stringauthors[], int numBooks, std::string author)
{

if (numBooks == 0)
{
std::cout << “No books are stored” << std::endl;
return;
}

bool bIsBookFound = false;
std::string* foundBooks = new std::string[numBooks];
int cnt = 0;
for (int i = 0;i < numBooks;i++)
{
if (authors[i] == author)
{
foundBooks[cnt] = titles[i];
cnt++;
bIsBookFound = true;
}
}

if(bIsBookFound)
{
std::cout << “Here is a list of books by ” << author<< std::endl;
for (int i = 0;i < cnt;i++)
std::cout << foundBooks[i] << std::endl;
}
else
{
std::cout << “There are no books by ” << author;
}

delete[] foundBooks;
  
}

Expert Answer


Answer to Would someone be able to break this C++ code down line by line and tell me what each line means? void printBooksByAuthor…

OR