/*this program adds two numbers
and save it into a file named sum_rslt.txt*/
#include< stdio.h>
#include< stdlib.h>
void main()
{
FILE *f;
char an='Y';
struct d
{
int a,b,c;
};
struct d e;
f=fopen("sum_rslt.txt","a+");
while(an=='Y')
{
printf("enter first no : ");
scanf("%d",&e.a);
fprintf(f,"\nfirst no : %d",e.a);
printf("\nenter second no : ");
scanf("%d",&e.b);
fprintf(f,"\nsecond no : %d",e.b);
e.c=(e.a+e.b);
fprintf(f,"\nreslt : %d\n\n\n",e.c);
printf("\n\npress Y to do again : ");
fflush(stdin);
an=getche();
printf("\n\n");
}
fclose(f);
}
This blog is for basic C programming language skills with interesting examples. It will help to the students who just started to learning C programming.
Tuesday, November 24, 2009
c file handling program example
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment