Back to Home & C
//Program to write and read employee details from a file
#include<stdio.h>
#include<conio.h>
void main()
{
int code;
char name[20];
FILE*fp;
fp=fopen("emp.dat","w+");
clrscr();
printf("Enter employee code");
scanf("%d",&code);
printf("Enter name");
scanf("%s",name);
printf("Writing to file...\n");
fprintfp("%d%s",code,name);
printf("Reading from file...\n");
fprint(fp,"%d%s",&code,name);
printf("Employee code=%d\n",code);
printf("Name=%s\n",name);
getch();
}
---------------------------------------------------------------------
Output :
=========================================================================
Back to Home & C
//Program to write and read employee details from a file
#include<stdio.h>
#include<conio.h>
void main()
{
int code;
char name[20];
FILE*fp;
fp=fopen("emp.dat","w+");
clrscr();
printf("Enter employee code");
scanf("%d",&code);
printf("Enter name");
scanf("%s",name);
printf("Writing to file...\n");
fprintfp("%d%s",code,name);
printf("Reading from file...\n");
fprint(fp,"%d%s",&code,name);
printf("Employee code=%d\n",code);
printf("Name=%s\n",name);
getch();
}
---------------------------------------------------------------------
Output :
=========================================================================
Back to Home & C
No comments:
Post a Comment