By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,898 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,898 IT Pros & Developers. It's quick & easy.

Help with filing

P: 1
I need a help for my project that is
"Design database of school information system"
Database of 10-20 schools having read and write capabilities using filing for future access to the given information using searching .


i didn't understand that what is filing?

i done a program in structure but don't know how to do in file please solve my problem ..i have to submit this with in a week...


#include<stdio.h>
#include<conio.h>
#include<graphics.h>
struct school
{
char name[100];
char pname[50];
int address;
int pnumb;
char schof[10];
char schtype[50];
char city[50];
};

struct school sch[100];
void main(void)
{
clrscr();
int i,index=0;
int left=18,top=7,right=60,bot=20;
int numcolors=18;
int j;
char repeat='Y';

do
{
printf("\nEntry No.%d\n",index);
printf("Enter school name:");
scanf("%s",sch[index].name);
printf("Enter principle name:");
scanf("%s",sch[index].pname);
printf("Enter street address:");
scanf("%d",sch[index].address);
printf("Enter phone number:");
scanf("%d",sch[index].pnumb);
printf("Enter city name in which it situated:");
scanf("%s",sch[index].city);
printf("Enter school education type:");
scanf("%s",sch[index].schof);
printf("Enter either school is primary or secondary:");
scanf("%s",sch[index].schtype);
index++;

if(index<20)
{
printf("DO YOU HAVE ANOTHER ENTRY? Y or N:");
repeat=getche();
putchar('\n');
}
}
while(index<20&&(repeat=='Y'||repeat=='y'));
clrscr();
gotoxy(18,5);
printf("---------------------------------------------");
window(left,top,right,bot);
for(j=0;j<20;j++);
{
textcolor(j%numcolors);
cputs("** DATABASE OF SCHOOL INFORMATION SYSTEM **");
}
gotoxy(0,3);
printf("--------------------------------------------");

for(i=0;i<index;i++)
{
printf("\n\t\tEntry No.%d\n",index);
printf("\n\n\t\t\tNAME OF SCHOOL:%s",sch[i].name);
printf("\n\n\t\t\tNAME OF PRINCIPLE:%s",sch[i].pname);
printf("\n\n\t\t\tADDRESS:%d",sch[i].address);
printf("\n\n\t\t\tPHONE NUMBER:%d",sch[i].pnumb);
printf("\n\n\t\t\tCITY:%s",sch[i].city);
printf("\n\n\t\t\tEDUCATION TYPE:%s",sch[i].schof);
printf("\n\n\t\t\tPRIMARY OR SECONDARY:%s\n",sch[i].schtype);
}

getch();
}
data base school information system in file
Nov 8 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
By filing it means write the data input to file and then may be at a later date read the file of data back into the program.

Look up the following functions for reading and writing files

fopen
fclose

fgets
fputs
fprintf

fread
fwrite
Nov 9 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.