Friday, 27 April 2012

Program Of File Structure In C++


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct emp
{
char name[40];
int age;
float bs;
};
main()
{
clrscr();
FILE *fp;
struct emp e;
char s[80];
char another='y';
fp=fopen("vEmployee.txt","w");
if(fp==NULL)
{
printf("Can't Open File");
exit(1);
}
printf("\n File  TEXT Is=");
printf("\n");
while(another=='y')
{
printf("\n Enter Name,AGE,Basic salary");
scanf("%s",e.name);
scanf("%d",&e.age);
scanf("%f",&e.bs);
fprintf(fp,"%s%d%f",e.name,e.age,e.bs);

printf("Add Another Record(y/n)");
fflush(stdin);
another=getche();
//scanf("%c",&another);

}
fclose(fp);a
getch();
}

No comments:

Post a Comment