0
when I try to enter any character value the Skip program in the option and I don’t even get a chance to write anyone knows why?
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int i=0;
struct pessoas {
char nomealuno[60];
int numeromeca;
char rua[90];
char curso[200];
int dia;
int mes;
int ano;
int nporta;
int codigopostal1;
int codigopostal2;
int num;
};
.....
case 1:
{
printf("Nome : ");
fgets(aluno[i].nomealuno, sizeof(aluno[i].nomealuno), stdin);
printf("Numero mecanografico : ");
scanf("%d",&aluno[i].numeromeca);
printf("Data de nascimento :\n ");
printf("dia.:");
scanf("%d",&aluno[i].dia);
printf("mes.:");
scanf("%d",&aluno[i].mes);
printf("ano.:");
scanf("%d",&aluno[i].ano);
printf("Rua : ");
fgets(aluno[i].rua, sizeof(aluno[i].rua), stdin);
printf("N da porta :");
scanf("%d",&aluno[i].nporta);
printf("codigo postal:");
scanf("%d",&aluno[i].codigopostal1);
printf("-");
scanf("%d",&aluno[i].codigopostal2);
printf("Em que curso pertence o aluno?");
fgets(aluno[i].curso, sizeof(aluno[i].curso), stdin);
}
.....
Do not post code image, post the code itself. It is impossible to have a complete view of what you wrote here on my device
– Jefferson Quesado
ok I’ll edit
– Kira
these are the necessary excerpts but if you want I can put the full code
– Kira
I think it’s just a problem in the read buffer. How do you read the option?
– Jefferson Quesado
read as machine or person? xD
– Kira
Programmatically read.
scanf
?fgets
and then compile the die in the hand?– Jefferson Quesado
Mostrar_aluno () { printf("Nome.: [%d] %s n",aluno[i]. nomeluno); printf("Numero mecanografico.: %8d n", aluno[i]. numeromeca); printf("Date of Birth.:%2d / %2d / %4d n",student[i]. day, student[i]. month, student[i]. year); printf("Street .: [%d] %s n",student[i]. street); printf("N of the door .: Nº %3d n",pupil[i]. nporta); printf("postal code .: %4d-%3d n",pupil[i]. codigopostal1,pupil[i]. codigopostal2); printf("Course .: [%d] %n",student[i]. course); }
– Kira
yes it is basically that way
– Kira
I asked you between two options and you said "yes"?
– Jefferson Quesado
then I did not understand what refers to sorry , can explain otherwise?
– Kira
You have a variable that is used in
switch
. This variable is informed by the user. How the program reads this information the user provides?– Jefferson Quesado
the information is all given in the previous case by the user the program at the beginning has not given any
– Kira