C Programming language

adplus-dvertising
C - File Operation : Opening a file
Previous Home Next

Some Other Program :

/* 
 * Program to append record to a file 
 */

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

void main()
{
	struct emprecord
{
char name[30];
int age;
float sal;
}emp;
FILE *fp;
int choice=1;
fp=fopen("employee.dat","ab");
if (fp==NULL)
{
printf("/n error in opening file"); exit(1); } while(choice==1 { printf("enter the name") scanff("%s\t",&emp.name); printf("enter the age"); scanf("%d\t",&emp.age); printf("enter the salery"); scanf("%f",&emp.sal); fwrite(&emp,sizeof(emp),1,fp); printf("want to enter more choice"); scanf("%d",&choice); } fclose(fp); getch(); };

 

Previous Home Next