我一直收到一条错误消息,指出"功能冲突类型'读取' &#34 ;.我的老师为我们的家庭作业编写了这个功能,但它似乎没有正确编译。这里是main之前的函数声明。
void flush();
void branching(char);
void read(); // The one that isn't working
void add(char*, char*, char*, char*, struct student*);
void display();
void save(char* fileName);
void load(char* fileName);
这里是读取功能:
void read()
{
char student_firstName[100];
char student_lastName[100];
char student_grade[30];
char student_level[100];
printf("\nEnter the student's first name:\n");
fgets(student_firstName, sizeof(student_firstName), stdin);
printf("\nEnter the student's last name:\n");
fgets(student_lastName, sizeof(student_lastName), stdin);
printf("\nEnter the student's grade (A+,A,A-,...):\n");
fgets(student_grade, sizeof(student_grade), stdin);
printf("\nEnter the student's education level (f/so/j/s):\n");
fgets(student_level, sizeof(student_level), stdin);
// discard '\n' chars attached to input; NOTE: If you are using GCC, you may need to comment out these 4 lines
student_firstName[strlen(student_firstName) - 1] = '\0';
student_lastName[strlen(student_lastName) - 1] = '\0';
student_grade[strlen(student_grade) - 1] = '\0';
student_level[strlen(student_level) - 1] = '\0';
add(student_firstName, student_lastName, student_grade, student_level, list);
printf("\n"); // newline for formatting
}
它还说隐含的功能声明'阅读'在C99中无效。
有谁知道为什么会发生这种情况以及如何解决这个问题?
答案 0 :(得分:2)
read()
是用于a function in the C standard library的名称;您不能将该名称用于程序中的函数。为您的功能选择一个更具体的名称,例如readStudent()
。