Here is my struct
struct Student
{
int numberofstudents;
float mid,prj,final,hmw;
int lettergrade;
int studentnumber;
char name[40];
char lastname[40];
int birthyear;
float totalgrade;
struct Student *next;
}* head;
And I have a function like this
void searchbylastname(char *lastname)
{
struct Student * temp = head;
while(temp!=NULL)
{
if(temp->lastname == lastname){
printf("Student Number: %d\n", temp->studentnumber);
printf("Name: %s\n", temp->name);
printf("Surname: %s\n", temp->lastname);
printf("Birth Year: %d\n", temp->birthyear);
printf("Total Grade: %0.2f\n", temp->totalgrade);
return;
}
temp = temp->next;
}
printf("Student with student number %s is not found !!!\n", lastname);
}
I'm calling it in main with switch case
head = NULL;
int choice;
char name[50];
char lastname[50];
int birthyear;
int studentnumber;
float totalgrade;
float prj,hmw,mid,final;
case 6:
printf("Enter student lastname to search: ");
scanf("%s", &lastname);
searchbylastname(lastname);
break;
but it cannot search by last name, it's automatically direct me here;
printf("Student with student number %s is not found !!!\n", lastname);
I don't know what to do, if anyone has an opinion, I would really appreciate it.