#include <stdio.h>
#include <stdlib.h>
#include "c.h"
#include <string.h>
typedef struct Element_s{
char songtitle[256], interpreter[256];
struct Element_s *next;
} Element_t;
void readFromkeyboard(Element_t *item){
if(!item);
fprintf(stdout, "Error");
return;
fprintf(stdout, "Welcher Song: ");
scanf("%s", item->songtitle);
while(getchar() != '\n'){}
fprintf(stderr, "Welcher Interpeter: ");
scanf("%s", item->interpreter);
while(getchar()!='\n'){}
}
Element_t *allocateElement(){
Element_t *new=0;
if(!(new=malloc(sizeof(Element_t)))){
fprintf(stderr, "Memory allocation error");
exit(-1);
}
readFromkeyboard(new);
new->next=0;
return new;
}
Element_t *insertLast(Element_t *list){
Element_t *new = allocateElement();
if(!list)
return new;
Element_t *last=list;
while(last->next)
last = last->next;
last->next = new;
return list;
}
void freeList(Element_t **list){
if(!list){
fprintf(stderr, "Nullpointer in freelist");
exit(-1);
}
Element_t *next;
while(*list){
next = list[0]->next;
free(list[0]);
list[0]=next;
}
list[0]=0;
}
void print_singleElement(Element_t *element)
{
if(element){
fprintf(stdout, "---")
}
}