Apply Now :

File Handeling in C Language

Monday, 12 December 2011

/* C Program => File Handeling
Calibre IT & Management Institute
[ Krishna suman ]
*/


#include<stdio.h>

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");
printf("\n \t Enter Your Choice : ");
scanf("%d",&choice);

switch(choice)
{
case 1:
printf("\n\t\t\t Information \n");
file1=fopen("Krishna.doc","w");


while((c=getchar())!=EOF)
{

putc(c,file1);
}
fclose(file1);
break;

case 2:
printf("\n\t\t\t Information\n");
printf("\nResult :");
file1=fopen("Krishna.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();
}






Share this Article on :

No comments:

Post a Comment