Monday 23 February 2015

FGETC() function in C


/* Character Oriented IO Functions */

#include<stdio.h>
#include<conio.h>
main()
{
char c;
FILE *p;

clrscr();

p=fopen("A.txt","w");
printf("\n Enter Details For To Store In a File");
c=getchar();
while(c!=EOF)
{
fputc(c,p);
c=getchar();
}
fclose(p);

p=fopen("A.txt","r");
printf("\n Contents Of The File\n");
c=fgetc(p);
while(c!=EOF)
{
putchar(c);
c=fgetc(p);
}
getch();
}

No comments:

Post a Comment