Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. typedef struct datei{
  4.   int wert;
  5.   struct datei *prev;
  6.   struct datei *next;        
  7. }DATEI;
  8.  
  9. DATEI *mom=0,*help=0,*first=0,*last=0;
  10.  
  11. void erzeugeDatei (int w);
  12.  
  13. int main(void){
  14.  erzeugeDatei(1);
  15.  erzeugeDatei(2);
  16.  //erzeugeDatei(3);
  17.  getch();    
  18. }
  19.  
  20. void erzeugeDatei(int w){
  21.   if(first==0){
  22.     mom=(DATEI *)malloc(sizeof(DATEI));
  23.     first=mom;
  24.     last=mom;
  25.     mom->prev=0;
  26.     mom->next=0;
  27.     help=mom;
  28.   }
  29.   if(first==mom){
  30.     mom=(DATEI *)malloc(sizeof(DATEI));
  31.     help->next=mom;
  32.     mom->prev=help;
  33.     mom->next=0;
  34.     last=mom;
  35.     help=mom;    
  36.   }
  37.   else{
  38.     DATEI *temp;
  39.     mom=(DATEI *)malloc(sizeof(DATEI));
  40.     temp=help->next;
  41.     help->next=mom;
  42.     mom->prev=help;
  43.     mom->next=temp;
  44.     temp->prev=mom;    
  45.   }      
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement