#include #include typedef struct node { int value; struct node *next; } node_t; node_t *first; void init() { first=NULL; } void print() { node_t *p = first; while(p != NULL) { printf("%2d, ", p->value); p = p->next; } printf("\n"); } void add(int a) { node_t *n = (node_t*) malloc (sizeof(node_t)); n->value = a; if(first!=NULL) n->next = first; else n->next = NULL; first = n; } int search(int s) { node_t *p = first; while(p != NULL) { if(p->value == s) return 1; // found it, extit the function p = p->next; } return 0; // could not find it } void delete_front() { if(first == NULL) return; // nothing to delete, list is already empty node_t *temp = first; first = first->next; free (temp); } int main() { init(); add(37); print(); add(99); print(); add(12); print(); printf("Search for 15 results in: %d\n", search(15)); printf("Search for 99 results in: %d\n", search(99)); delete_front(); print(); system("pause"); }