Skip to content

Instantly share code, notes, and snippets.

@lumaxis
Created January 27, 2012 22:11
Show Gist options
  • Save lumaxis/1691199 to your computer and use it in GitHub Desktop.
Save lumaxis/1691199 to your computer and use it in GitHub Desktop.
Verkettete Liste
#include <stdio.h>
#include <stdlib.h>
struct IntKnotenStruct {
int data;
struct IntKnotenStruct *next;
struct IntKnotenStruct *prev;
};
typedef struct IntKnotenStruct IntKnoten;
void ausgabe(IntKnoten *k)
{
printf("Ausgabe:\n");
while (k!=NULL){
printf("%d\n", k->data);
k = k->next;
}
}
int main(int argc, char* argv[])
{
int zahl;
IntKnoten *start, *k1, *k2, *k3;
k1 = (IntKnoten*)malloc(sizeof(IntKnoten));
k2 = (IntKnoten*)malloc(sizeof(IntKnoten));
k3 = (IntKnoten*)malloc(sizeof(IntKnoten));
start = k1;
k1->data = 3;
k1->next = k2;
k1->prev = NULL;
k2->data = 5;
k2->next = k3;
k2->prev = k1;
k3->data = 8;
k3->next = NULL;
k3->prev = k2;
ausgabe(start);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment