Write a function called Get_Info that takes a pointer to a student structure, (t
ID: 3647520 • Letter: W
Question
Write a function called Get_Info that takes a pointer to a student structure, (that has three fields: char array called name, an int id, and a double gpa) as its only argument. The function prompts the user for the required information to fill the structure and stores it in the appropriate fields.Do not copy from the google sites.
Explanation / Answer
#include #include typedef struct student{ char *name; int id; double gpa; }student; void Get_Info(student *stu); int main() { student *stu; stu=(student *)malloc(sizeof(student)); Get_Info(stu); printf(" %s with id %d has a gpa of %lf ",stu->name,stu->id,stu->gpa); } void Get_Info(student *stu) { stu->name = (char*)calloc(100*sizeof(char)); printf(" Enter the name of the student: "); scanf("%s",&(stu->name)); printf(" Enter the id of the student: "); scanf("%d",&(stu->id)); printf(" Enter the GPA of the student: "); scanf("%lf",&(stu->gpa)); return; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.