I keep getting an error that says "conflicting types for function 'read' ". My teacher wrote that function for our homework assignment, but it doesn't seem to be compiling correctly. Here's the declaration of the functions before 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);
Here's the read function:
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
}
It's also saying implicit declaration of function 'read' is invalid in C99.
Does anyone know why this is happening and how to fix it?
readis a predefined function in C . Try a different function name . - ameyCUread()doesn't have access to either of your snippets. We'll need to see more of your code. - jwodderread()with a very different signature declared in<unistd.h>, so if you include that, you'll get the conflicting types error message. However, if you don't include that, you should be OK — treading on thin ice, but you should get away with (but don't jump). - Jonathan Leffler<unistd.h> is not included in the programhave you checked all headers that you include? and all headers that these headers include? and all headers that these headers include? - n. 1.8e9-where's-my-share m.