Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct aluno
- {
- int num;
- char nome[10];
- float nota;
- }Aluno;
- int main()
- {
- Aluno a,b;
- a.num=100;
- strcpy(a.nome, "Aluno");
- a.nota=9.5;
- FILE *fp = fopen("saidaBin.bin","wb"); //gravação binario
- fwrite(&a, sizeof(Aluno),1,fp);
- fclose(fp);
- fp=fopen("saidaBin.bin","rb"); //leitura binário
- fread(&b, sizeof(Aluno),1,fp);
- printf("\nDados gravados:\nNum: %d, Nome: %s, Nota= %.1f\n\n",b.num,b.nome,b.nota);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement