Monday 23 February 2015

FORMATED IOFUNCTION IN C


/*  Formatted IO Functions  */

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

clrscr();

p=fopen("A.txt","w");

printf("\n Enter The Contents\n");
while(gets(c)!=NULL)
{
fprintf(p,"%s",c);
}
fclose(p);

p=fopen("A.txt","r");

printf("\n File Contents\n");

while(fscanf(p,"%s",c)!=EOF)
{
puts(c);
}
getch();
}

No comments:

Post a Comment