Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<stdlib.h>
- void funcCadastro(struct cadastro *aluno);
- void funcPrinta(struct cadastro *aluno);
- struct cadastro
- {
- int ra;
- struct cadastro *prox;
- };
- void funcPrinta(struct cadastro *aluno)
- {
- struct cadastro *atual;
- atual = aluno;
- if (atual->prox == NULL)
- {
- return;
- }
- atual = atual->prox;
- while (atual != NULL)
- {
- printf("\n%d", atual->ra);
- atual = atual->prox;
- }
- }
- void funcCadastro(struct cadastro *aluno)
- {
- struct cadastro *atual;
- struct cadastro *temp;
- int op;
- atual = aluno;
- temp = (struct cadastro*)malloc(sizeof(struct cadastro));
- printf("Digite quantos RA's deseja cadastrar:");
- scanf("%d", &op);
- for (int i = 0; i < op; i++)
- {
- printf("\nDigite um ra:");
- scanf("%d", &(aluno->ra));
- temp->prox = NULL;
- while (atual->prox != NULL)
- {
- atual = atual->prox;
- }
- atual->prox = temp;
- }
- }
- void main()
- {
- struct cadastro aluno;
- aluno.ra = -1;
- aluno.prox = NULL;
- funcCadastro(&aluno);
- funcPrinta(&aluno);
- fflush(stdin);
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement