The purpose of the code is to store library card information and search for books using author's last name. When I search using author's name, it says "no books by this author last name found". Below is my code. What am I doing wrong here?
//Program to store Library card Information and search for record using last name
#include<stdio.h>
void search(struct lib_card *name)
struct author
{
char fname[20];
char lname[20];
};
struct pub_date
{
int day;
int month;
int year;
};
struct lib_card //Structure declaration for storing Library card information
{
char title[80];
struct author name;
struct pub_date date;
};
void main()
{
struct lib_card card[2];
int l; //l is a variable assigned for loop
for (l = 0; l < 2; l++)
{
printf("********Enter Library Card Information********\n");
printf("Card # %d\n", l + 1);
printf("Enter Book Title: ");
scanf("\n%[^\n]s", card[l].title);
printf("Enter Author's First name: ");
scanf("\n%s", card[l].name.fname);
printf("Enter Author's Last name: ");
scanf("\n%[^\n]s", card[l].name.lname);
printf("\nEnter Published date:\n");
printf("\t\tdate(dd):");
scanf("\n%d", &card[l].date.day);
printf("\t\tMonth(mm):");
scanf("\n%d", &card[l].date.month);
printf("\t\t\Year(yy):");
scanf("\n%d", &card[l].date.year);
}
search(card); //Structure's address is passed to search function
}
void search(struct lib_card *name)
{
char llastname[20];
int l;
printf("\nEnter Author's Last name to search for books:");
scanf("\n%[^\n]s", llastname); //Get author's last name to search the books
for (l = 0; l < 2; l++)
{
printf("%s\n", (name + l)->name.lname);
if ((name + l)->name.lname == llastname)
{
printf("%s\n", (name + l)->title);
}
else if (l == 1)
{
printf("\nNo books by this Author's Last name found");
}
}
}