For my assignment I have to create a structure that allows the user to enter student info (ID, DOB, & Phone number). I have no problem doing this that is quite simple. Now I need to search through that enter info using the student ID to display that students corresponding DOB and phone number, this is the problem that I am having trouble working with. If you see any other problems with my program please let me know what is wrong and why I should change so I can learn from my mistakes.
I'm also not sure how to store all these different parts of the students info to an array and have them correspond to each other. So when I search an ID how does it know to return the correct DOB and phone. I'm really lost here guys and needing some help. What ever you tell me or if you give me code, please explain why I should be doing what you're telling me to do.
NOTE: All my classes are online so getting hold of my professor for help is a challenge, so I've turn to you guys for help.
#include <stdio.h>
#include <stdlib.h>
struct infoStruct
{
int studentID;
int year;
int month;
int day;
int phone;
int end;
};
int main (void)
{
int students = 0;
int infoArray [students];
struct infoStruct info;
int studentID;
int year;
int month;
int day;
int phone;
int end;
while (info.end != -1) {
students = students + 1;
printf("Enter student information (ID, day, month, year, phone)
");
printf("Enter -1 following the phone number to end the process to continue enter 0
");
scanf("%d %d %d %d %d %d", &info.studentID, &info.day, &info.month, &info.year, &info.phone, &info.end);
}
if (info.end = -1){
printf("You entered %d student(s)
", students);
}
//Student Search
printf("Please enter the student ID of the student your looking for
.");
scanf("%d", info.studentID);
printf(" DOB: %d %d %d, Phone: %d", info.month, info.day, info.year, info.phone);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…