Question: #include #include #include typedef struct student{ char first_name[30]; char last_name[30]; char email[50]; int id; }student; student *enter(){ int i; student *students = (student *) malloc(3

#include #include #include

typedef struct student{ char first_name[30]; char last_name[30]; char email[50]; int id; }student;

student *enter(){ int i; student *students = (student *) malloc(3 * sizeof(student)); char domain[] = "@domain.com"; for(i = 0; i < 3; ++i){ printf("Enter student %d details ", i+1); printf("First name: "); scanf("%s", students[i].first_name); printf("Last name: "); scanf("%s", students[i].last_name); students[i].email[0] = 0; strcat(students[i].email, students[i].first_name); strcat(students[i].email, students[i].last_name); strcat(students[i].email, domain); students[i].id = i + 1; } return students; }

void search(student *students){ char name[30]; int i; printf("Enter last name to search: "); scanf("%s", name); for(i = 0; i < 3; ++i){ if(strcmp(students[i].last_name, name) == 0){ printf("First name: %s ", students[i].first_name); printf("Email: %s ", students[i].email); printf("Id: %d ", students[i].id); } } }

int main(){ student *students = enter(); search(students); return 0; }

Update this code with delete and sorting capabilities.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!