#include "stdafx.h" #include "seznam.h" void listShow(listDescr *list) { item *temp; temp=list->first; if (temp == NULL) puts("List Empty"); else { printf("\nFirst: %08X\n", temp); // show address of first for(; temp; temp = temp->next) printf("Count: %3d, addr: %08x, next: %08x, text: %s\n", temp->count, temp, temp->next, temp->word); // addresses and data } } bool listClear(listDescr *list) { if (list->first == NULL) return false; while(list->first) { item *temp = list->first->next; free(list->first); list->first = temp; } return true; } bool listAdd(listDescr *list, char *txt) { item *temp; for(temp = list->first; temp; temp = temp->next) // iterace for all items { if (strcmp(temp->word, txt) == 0) // identical ? { temp->count++; // inkrement counter return true; // end of function } } if (NULL == (temp = (item *)malloc(sizeof(item)+strlen(txt)+1))) return false; // cannot allocate heap memory temp->word=((char *)temp)+sizeof(item); strcpy(temp->word, txt); // copy text temp->count = 1; // default count temp->next = list->first; // next of this new is previously first list->first = temp; // first will be this newest return true; } HAHA HAHAHA HAHAHAHA !!ahoj ~~ahoj }}ahoj