Prog#234: read until name !=$ & write into file


#1
/*
read until name !=$ & write into file
Program#234
*/
#include<stdio.h>
main(int argc,char *argv[])
{
int i,p;
char a[512];
union xyz{
struct bio{
char name [20], addr [20];
int age;
float salary;
}a;
char b[sizeof(struct bio)];
};
union xyz m;
if(argc!=2)
{
printf("error: no.of arg");
return 0;
}
p=open(argv[1], 1);
if(p==-1)
{
printf("file open error");
return 0;
}
scanf("%s", m.a.name);
while(m.a.name[0]!='$')
{
scanf("%d %f %s", & m.a.age, & m.a.salary, m.a.addr);
i=write(p,m.b,sizeof(struct bio));
scanf("%s", m.a.name);
}
close(p);
}