This is a C program on file Handling
/************** File Handling *************/
void main()
{
FILE *file1;
char c;
int choice;
char op;
clrscr();
do
{
printf(“\t\tMenu\n\t1. Enter The Information\n\t2. Display The Information\n”);
scanf(“%d”,&choice);
switch(choice)
{
case 1:
printf(“\n Information \n”);
file1=fopen(“Handlin.doc”,”w”);
while((c=getchar())!=EOF)
{
putc(c,file1);
}
fclose(file1);
break;
case 2:
printf(“Information\n”);
printf(“Result :”);
file1=fopen(“Malcolm .doc”,”r”);
while((c=getc(file1))!=EOF)
printf(“%c”,c);
fclose(file1);
break;
default:
exit(1);
}
printf(“Enter Y To Continue:”);
flushall();
scanf(“%c”,&op);
}
while((op==’y')(op==’Y'));
getch();
}
/********************* OUTPUT **********************
Menu
1. Enter The Information
2. Display The Information
1
Information
Today Is Sunday
^Z
Enter Y To Continue:y
Menu
1. Enter The Information
2. Display The Information
2
Information
Result :
Today Is Sunday
Enter Y To Continue:n
*/