1
Hello, I have to check the grades of a certain student and if his average is greater than 5 show the name so I have no idea how to do it... nor to ask how does it so excuse me if I was unclear
struct ALUNOS{
char nome[50];
float nota1, nota2;
}aluno;
void cadastra(){
FILE *arquivo;
ALUNOS aluno;
char resp, numstr[40];
arquivo = fopen("alunoscad.txt","wt");
if (arquivo == NULL){
printf("\n Erro abertura!");
exit(1);
}
do{
printf("\n Nome: ");
gets(aluno.nome);
printf("\n Nota 1: ");
gets(numstr);
aluno.nota1 = atof(numstr);
printf("\n Nota 2: ");
gets(numstr);
aluno.nota2 = atof(numstr);
fprintf(arquivo,"%s",aluno.nome);
fprintf(arquivo,"\n%.2f",aluno.nota1);
fprintf(arquivo,"\n%.2f\n",aluno.nota2);
printf("\n Deseja cadastrar mais? \n");
do {
resp = toupper(getch());
} while (resp != 'S' && resp != 'N');
}while(resp=='S');
fclose(arquivo);
}
void mostra (){
FILE *arquivo;
ALUNOS aluno;
char ch;
int achou = 0;
if ((arquivo = fopen("alunoscad.txt", "rt")) == NULL){
printf("\n Erro abertura");
exit(1);
}
while ((ch = getc(arquivo)) !=EOF){
fgets()
}
fclose (arquivo);
}
int main(){
cadastra();
mostra();
}
this is all my code
Ola Giovanni Dias, I suggest you take the tour to learn how to ask: http://answall.com/tour. A way to search in text files and using regular expressions, or you can mark up your file to make it easier to search.
– gato