Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct objecto produto, *pprod;
- struct objecto{
- char nome[100];
- int quantidade;
- pprod prox;
- };
- produto t[4][3];
- int lista_vazia(pprod p)
- {
- if(p == NULL)
- return 1;
- else
- return 0;
- }
- void mostra_info(pprod p)
- {
- while(p != NULL)
- {
- printf("%s\t%d\n",
- p->nome, p->quantidade);
- p = p->prox;
- } }
- void preenche(pprod p)
- {
- printf("Nome: ");
- scanf("%s",p->nome);
- printf("Quantidade: ");
- scanf("%d",&p->quantidade);
- p->prox = NULL;
- }
- pprod insere_inicio(pprod p)
- {
- pprod novo;
- if((novo = malloc(sizeof(produto))) == NULL)
- printf("Erro na alocacao de memoria\n");
- else
- {
- preenche(novo);
- novo->prox = p; } p = novo;
- return p;
- }
- int main(int argc, char *argv[]){
- insere_inicio(t[0][0].prox);
- mostra_info(t[0][0].prox);
- printf("%d",lista_vazia(t[0][0].prox));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement