Guest User

Untitled

a guest
Jan 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. typedef struct pallet{
  6.     int id;
  7.     int alturapallet;
  8.     int fecha;
  9.     struct pallet *sig;
  10.     struct pallet *ant;
  11. } tPallet;
  12.  
  13.  
  14. typedef struct {
  15.     tPallet *head;
  16.     tPallet *tail;
  17.     tPallet *curr;
  18.     unsigned int listSize;
  19.     unsigned int pos;
  20. } tLista;
  21.  
  22. void initList (tLista *B){
  23.     B->curr=(tPallet *)malloc(sizeof(tPallet));
  24.     B->head=B->curr;
  25.     B->head=B->tail;
  26.     B->listSize=0;
  27.     B->pos=0;
  28. }
  29.  
  30. void insert (tLista*B, int valor){
  31.     tPallet *aux = B->curr->sig;
  32.     B->curr->sig=(tPallet *)malloc(sizeof(tPallet));
  33.     B->curr->sig->id=valor;
  34.     B->curr->sig->sig=aux;
  35.     if(B->curr==B->tail) B->tail = B->curr->sig;
  36.     B->listSize++;
  37. }
  38.  
  39. int main(){
  40.     tLista *B=(tLista *)malloc(sizeof(tLista));
  41.     initList(B);
  42.     insert(B,9);
  43.     printf("%d",B->curr->sig->id);
  44.     return 0;
  45. }
Add Comment
Please, Sign In to add comment