对于我的任务,我将创建一个允许用户输入学生信息(ID、DOB 和电话号码)的结构。这样做很简单,我没有问题。现在我需要使用学生 ID 搜索输入信息以显示学生对应的 DOB 和电话号码,这是我无法解决的问题。如果您发现我的程序有任何其他问题,请让我知道哪里出了问题以及为什么我应该更改,以便我可以从错误中吸取教训。
谢谢你。
#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)\n");
printf("Enter -1 following the phone number to end the process to continue enter 0\n");
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)\n", students);
}
//Student Search
printf("Please enter the student ID of the student your looking for\n.");
scanf("%d", info.studentID);
printf(" DOB: %d %d %d, Phone: %d", info.month, info.day, info.year, info.phone);
}