0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<locale.h>
int main()
{
struct aluno{
char nome[30];
int n_matricula;
char curso[30];
};
struct aluno alunos[5];
int numero;
for(numero=1; numero<=5; numero++)
{
printf("Nome do aluno %i.................: ",numero); gets(alunos[numero].nome);
printf("Curso do aluno %i................: ",numero); gets(alunos[numero].curso);
printf("Numero da matricula do aluno %i..: ",numero); scanf("%i",&alunos[numero].n_matricula);
printf("\n\n\n");
}
printf("\n\n_____________________________________________\n\n");
printf("Alunos:\n\n");
for(numero=1; numero<=5; numero++)
{
printf("\n----------------------\n"); printf("%s",alunos[numero].nome); printf("\n----------------------\n");
printf("\n----------------------\n"); printf("%s",alunos[numero].curso); printf("\n----------------------\n");
printf("\n----------------------\n"); printf("%s",alunos[numero].n_matricula); printf("\n----------------------\n");
}
return 0;
}
Do not elaborate questions only with code. Detail your problem as much as possible so that those who read your question can understand. I can already say that there are some mistakes how to use
%s
to read numbers, and mixgets
withscanf
– Isac
Thank you for warning
– Julio Faria
The index of an array in C part of 0 and not 1.
– anonimo
First of all, look how and why to accept an answer.
– sbrubes