Friday, April 17, 2009

FERROR

#include
void main()
{
FILE *fp;
char name[20];int marks;
clrscr();
fp=fopen("s1.txt","r");
if(fp==NULL)
{
printf("file is not found\n");
exit();
}
printf("Enter name and marks\n");
scanf("%s%d",name,&marks);

fprintf(fp,"%s%d",name,marks);
if(ferror(fp))
{
printf(" unable to write date\n");
fclose(fp);
}
}

No comments: