All pastes #18647 Raw Edit

Untitled

public text v1 · immutable
#18647 ·published 2005-07-27 18:36 UTC
rendered paste body
Header Code:
#include <stdio.h>
        struct person {
        char name[80];
        int age;
        char sex;
        int month;
        int day;
        int year;

        };

Program Code:
#include "/home/cordless/chomework/headerlib/dbstruct.h"

int main() {
  FILE *database;

  struct person person[10];

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);