Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- // definição de um registro aluno
- struct aluno {
- char *nome;
- char *ru;
- };
- int main (void) {
- int nEstudantes = 0; // numero de estudantes
- printf("Digite o numero de estudantes que deseja cadastrar: ");
- scanf("%d", &nEstudantes);
- for (int i=0; i<nEstudantes; i++) {
- struct aluno al; // declaração de um registro aluno
- printf("Digite o nome do estudante nº%d: ", i);
- char *nome = malloc(sizeof(char[50]));
- scanf("%s", nome);
- al.nome = nome;
- printf("O aluno de nº %d foi cadastrado com o nome %s\n", i+1, al.nome);
- free(nome);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement