我在做这件事时遇到了一点麻烦。我正在创建一个程序,该程序将使用结构按 ID 号存储个人信息。然后我需要将其存储在一个数组中,然后使用 for 循环(简单)搜索它。每当我尝试编译时,我都会收到一条错误消息,说请求成员“blah blah”,而不是结构或联合。
最后的 printf 语句出现此错误。
#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;
struct infoStruct *info = NULL;
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");
info = malloc(sizeof(struct infoStruct) * students);
scanf("%d %d %d %d %d %d", &info.studentID, &info.day, &info.month, &info.year, &info.phone, &info.end);
}
printf("You entered %d student(s)\n", students);
printf("Enter Student ID\n");
scanf("%d", info.studentID);
}