Header Code:
#include <stdio.h>
struct person {
char name[80];
int age;
char sex;
int month;
int day;
int year;
};
Program Code:
#include "dbstruct.h"
int main() {
FILE *database
int i;
for(i=0;i<=9;i++) {
printf("Enter the persons Name: ");
scanf("%s",person[i].name);
printf("Enter the person's Age: ");
scanf("%d",&(person[i].age));
printf("Enter the person's Sex (M or F): ");
getchar();
scanf("%c",&(person[i].sex));
printf("Enter the person's Birth Date (DD/MM/YYYY): ");
scanf("%d/%d/%d",&(person[i].day),&(person[i].month),&(person[i].year));
}
database=fopen("mycensus.dat","wb");
fwrite(person,sizeof(struct person),10,database);
fclose(database);
return(0);
}
Errors:
bash-3.00$ gcc -o databaseprog -Wall databaseprog.c
databaseprog.c: In function `main':
databaseprog.c:6: error: syntax error before "int"
databaseprog.c:8: error: `i' undeclared (first use in this function)
databaseprog.c:8: error: (Each undeclared identifier is reported only once
databaseprog.c:8: error: for each function it appears in.)
databaseprog.c:10: error: `person' undeclared (first use in this function)
databaseprog.c:21: error: `database' undeclared (first use in this function)