c - Am I using structs in the wrong way? -
i have come across wierd , mysterous (at least me) error finding hard time finding. gives me error @ line call function input(student_list1[max], &total_entries);
compiler says:
incompatible type agument 1 in 'input'
what doing wrong here? sense simple , stupid have gone through code several times without avail.
#define max 10 #define name_len 15 struct person { char name[name_len+1]; int age; }; void input(struct person student_list1[max], int *total_entries); int main(void) { struct person student_list1[max]; int total_entries=0, i; input(student_list1[max], &total_entries); for(i=0; i<total_entries; i++) { printf("student 1:\tnamn: %s.\tage: %s.\n", student_list1[i].name, student_list1[i].age); } return 0; } //main end void input(struct person student_list1[max], int *total_entries) { int done=0; while(done!=1) { int i=0; printf("name of student: "); fgets(student_list1[i].name, strlen(student_list1[i].name), stdin); student_list1[i].name[strlen(student_list1[i].name)-1]=0; if(student_list1[i].name==0) { done=1; } else { printf("age of student: "); scanf("%d", student_list1[i].age); *total_entries++; i++; } } }
input(student_list1[max], &total_entries);
shoud input(student_list1, &total_entries);
.
in c,
void input(struct person student_list1[max], int *total_entries);
equals
void input(struct person *student_list1, int *total_entries);
Comments
Post a Comment