#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
FILE *fp;
char another='y';
struct emp
{
char name[40];
int age;
float bs;
};
struct emp e;
fp=fopen("EMPLOYEE.doc","w");
if(fp==NULL)
{
puts("Cannot open file");
exit(1);
}
while(another=='y')
{
printf("\nEnter Name: ");
scanf("%s",&e.name);
printf("Enter age: ");
scanf("%d",&e.age);
printf("Enter salary: ");
scanf("%f",&e.bs);
fprintf(fp,"%s\t%d\t%f\n",e.name,e.age,e.bs);
printf("Add Another Record (y/n): ");
fflush(stdin);
another=getche();
}
fclose(fp);
return 0;
}
#include <conio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
FILE *fp;
char another='y';
struct emp
{
char name[40];
int age;
float bs;
};
struct emp e;
fp=fopen("EMPLOYEE.doc","w");
if(fp==NULL)
{
puts("Cannot open file");
exit(1);
}
while(another=='y')
{
printf("\nEnter Name: ");
scanf("%s",&e.name);
printf("Enter age: ");
scanf("%d",&e.age);
printf("Enter salary: ");
scanf("%f",&e.bs);
fprintf(fp,"%s\t%d\t%f\n",e.name,e.age,e.bs);
printf("Add Another Record (y/n): ");
fflush(stdin);
another=getche();
}
fclose(fp);
return 0;
}
No comments:
Post a Comment