Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Como eu faço a estrutura desse programa conforme as perguntas.

0 votes
asked Apr 20, 2021 by paulo magalhaes (1,480 points)
Escreva um programa que armazene em um arquivo o RGA, Nome e Nota de 5 alunos e, após a escrita, escreva o RGA, Nome e Nota dos alunos que possuem Nota acima de 7.

*Escreva o programa utilizando arquivo binário.

*Faça uma segunda solução utilizando arquivo texto.

1 Answer

0 votes
answered Apr 20, 2021 by Peter Minarik (86,640 points)
edited Apr 20, 2021 by Peter Minarik

You have to use the same techniques you've used in

The main difference is that for binary mode you've got to use "b" when opening a file with fopen:

FILE * file = fopen(fileName, "rb");
commented Apr 29, 2021 by paulo magalhaes (1,480 points)
Fiz o programa mas ainda apresenta erros. Gostaria de uma ajuda para deixa-lo mais apresentavel.

#include <stdio.h>
#include <string.h>
#define TAM 5 //tamanho do vetor usado como cadastro
void imprimeArquivo(){
Aluno cadastro[5];
FILE *arq = fopen(nomeArq, "r+b"); //Note que usamos r e n~ao w
int i;
if(arq == NULL){
printf("Erro: Imprime Arquivo!\n");
return;
}
fread(cadastro, sizeof(Aluno), TAM, arq);
printf(" ---- Imprimindo Dados ----\n");
for(i=0; i<TAM; i++){
printf("nome: %s, rga: %s, nota:f \n", cadastro[i].nome, cadastro[i].rga, cadastro[i].nota);
}
printf("\n");
fclose(arq);
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...