Crise cad.c
From AdonaiMedrado.Pro.Br
Revision as of 21:39, 12 June 2009 by Adonaimedrado (Talk | contribs) (New page: <code lang="c"> #include <stdio.h> struct folha { char servidor[51]; int idade; int salario; }; int main(void) { FILE *fp = fopen("crise.dat","a+"); int i,n; struct folha *fl, *tb;...)
#include <stdio.h> struct folha { char servidor[51]; int idade; int salario; }; int main(void) { FILE *fp = fopen("crise.dat","a+"); int i,n; struct folha *fl, *tb; scanf("%d",&n); fl=malloc(sizeof(struct folha)*n); for(i=0,tb=fl;i<n;i++,tb=fl+i) scanf("%s %d %d",tb->servidor,&(tb->idade),&(tb->salario)); fwrite(fl,sizeof(struct folha),n,fp); free(fl); fclose(fp); return 0; }