Monday 23 February 2015

FGETS() FUNCTION IN C


/* String Orinted IO Functions */

#include<stdio.h>
#include<conio.h>
main()
{
char c[80];
FILE *p;
clrscr();
p=fopen("A.txt","w");
printf("\n Enter Details For To Store In a File");

while(gets(c)!=NULL)
{
fputs(c,p);
}
fclose(p);

p=fopen("A.txt","r");
printf("\n Contents Of The File\n");

while(fgets(c,80,p)!=NULL)
{
puts(c);
}
getch();
}

No comments:

Post a Comment