Last active
August 29, 2015 14:18
-
-
Save Drowze/246c55ab19eab25ae5a9 to your computer and use it in GitHub Desktop.
delete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
struct s_aluno{ | |
int ra; | |
char nome[52]; | |
float nota; | |
struct s_aluno *prox; | |
}; | |
typedef struct s_aluno s_aluno; | |
void insere_aluno(s_aluno **pplista){ //insere struct no inicio | |
s_aluno *no = (s_aluno *)malloc(sizeof(s_aluno)); | |
no->ra = 10; | |
strcpy(no->nome,"Rafael"); | |
if(**pplista != NULL) // verifico se a lista nao ta vazia | |
no->prox = *pplista; //se nao tiver, ponteiro do no aponta para onde apontava o ponteiro do inicio da lista | |
pplista = no; //lista agora aponta para onde o nó aponta | |
} | |
void exibe_alunos(s_aluno *pplista){ | |
s_aluno *p; | |
for(p = pplista; p!=NULL; p = p->prox) | |
printf("%s",p->nome); | |
} | |
int main(){ | |
s_aluno *Lista = NULL; //ponteiro pro começo da lista (que no começo é nula) | |
insere_aluno(&Lista); | |
exibe_alunos(Lista); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment