REPLY TO REGISTRATION QUESTION
Posted by mark123
Last Updated: February 29, 2012
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<conio.h>
typedef struct{
char fullname[51];
char idnum[15];
char DOB[11];
char address[31];
}students;
void studentregist();
void main()
{
studentregist();
system("pause");
}
void studentregist()
{
students record;
char answer;
FILE *pfile;//this will be used to store the contents of password
if((pfile=fopen("password.txt","w") )==NULL)
{
printf("ERROR FILE COULD NOT BE OPENED\n");
}
else
{
while(answer=='y')
{
fflush(stdin);
printf("Please enter full name of student:\n");
fgets(record.fullname,51,stdin);
printf("Please enter student id number:\n");
scanf("%s",record.idnum);
fflush(stdin);
printf("Please enter the address of the student:\n");
fgets(record.address,31,stdin);
printf("Please enter the date of birth of the student:\n");
scanf("%s",record.DOB);
fflush(stdin);
printf("Any more records(y/n)?\n");
scanf("%c",answer);
}
while(!feof(stdin))
{
fprintf(pfile,"Name:%s\n",record.fullname);
fprintf(pfile,"ID NUMBER%s\n",record.idnum);
fprintf(pfile,"ADDRESS:%s\n",record.address);
fprintf(pfile,"DATE OF BIRTH: %s\n",record.DOB);
}
fclose(pfile);
}
Related Content