0
I have to make a program with options menu that allows me to read a student’s information, write their name and phone after entering their student number, and determine how many students are older than the user’s age. The program runs, but does not save the data. I wondered if you can help me in this problem!!
#include <stdio.h>
struct aluno{
int numero;
char nome[100];
char morada[100];
int idade;
int telefone;
};
void infoPerson(struct aluno *Turma, int *i) {
for (int i = 0; i < 50; i++) {
printf("Introduza o número \n");
scanf(" %d", &Turma->numero);
printf("Introduza a idade \n");
scanf(" %d", &Turma->idade);
printf("Introduza o telefone \n");
scanf(" %d", &Turma->telefone);
printf("Introduza o nome \n");
scanf(" %s", &Turma->nome[100]);
printf("Introduza a morada \n");
scanf(" %s", &Turma->morada[100]);
}
}
int main() {
int opc;
int i = 0;
struct aluno *Turma[2];
do{
do{
printf("1 - Introduzir alunos\n");
printf("2 - Teste\n");
printf("3 - Teste\n");
scanf("%d", &opc);
} while (opc < 0 || opc > 3);
switch (opc){
case 1:
infoPerson(Turma, &i);
break;
case 2:
printf("\n");
break;
case 3:
printf("\n");
break;
default:
printf("Teste\n");
}
} while (opc < 0 || opc > 3);
}
This code does not even compile into a properly configured compiler.
– Maniero
In my IDE (Clion) it runs with some errors.
– João Carvalho
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero