Language: C

/* 
 * File:   main.c
 * Author: Ivan
 *
 * Created on June 25, 2018, 7:45 PM
 */

#include <stdio.h>
#include <stdlib.h>

struct Item {
    int key;
    Item *next, *prev;
};
//typedef struct{
//    int key;
//    Item *next;
//    Item *prev;
//}Item;

Item *null;

Item *search(int key);

void print();

void deleteItem(Item *m);

void insert(int key);

/*
 * 
 */

//int main(int argc, char** argv) {
int main() {
    int key, n, np = 0, nd = 0, size = 0;
    char command[50];
    
    scanf("%d", &n);
    
    null = (Item *)malloc(sizeof(Item));
    null->next = null;
    null->prev = null;
    
    for (int i = 0; i < n; ++i)
    {
        scanf("%s%d", command, &key);
        if (command == "insert") { insert(key); np++; size++; }
        else if ( command == "deleteFirst") { deleteItem(null->next); size--; }
        else if ( command == "deleteLast") { deleteItem(null->prev); size--; }
        else { deleteItem(search(key)); size--; }
    }
    
    print();
    
    return (EXIT_SUCCESS);
}

Item *search(int key)
{
    Item *current = null->next;
    while ( current != null && current->key != key)
    {
        current = current->next;
    }
    return current;
}

void print()
{
    Item *current = null->next;
    printf("%d", current->key);
    while (1)
    {
        if (current == null) break;
        printf(" ");
        printf("%d", current->key);
        current = current->next;
    }
    printf("\n");
}

void deleteItem(Item *m)
{
    if (m == null) return;
    m->prev->next = m->next;
    m->next->prev = m->prev;
    free(m);
}

void insert(int key)
{
    Item *x = (Item *)malloc(sizeof(Item));
    x->key = key;
    x->next = null->next;
    null->next->prev = x;
    null->next = x;
    x->prev = null;
}



Compiler output:
main.c:13:5: error: unknown type name 'Item'
   13 |     Item *next, *prev;
      |     ^~~~
main.c:21:1: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   21 | Item *null;
      | ^~~~
      | struct 
main.c:23:1: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   23 | Item *search(int key);
      | ^~~~
      | struct 
main.c:27:17: error: unknown type name 'Item'
   27 | void deleteItem(Item *m);
      |                 ^~~~
main.c: In function 'main':
main.c:42:13: error: 'Item' undeclared (first use in this function)
   42 |     null = (Item *)malloc(sizeof(Item));
      |             ^~~~
main.c:42:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:42:19: error: expected expression before ')' token
   42 |     null = (Item *)malloc(sizeof(Item));
      |                   ^
main.c:43:9: error: request for member 'next' in something not a structure or union
   43 |     null->next = null;
      |         ^~
main.c:44:9: error: request for member 'prev' in something not a structure or union
   44 |     null->prev = null;
      |         ^~
main.c:50:47: error: implicit declaration of function 'deleteItem' [-Wimplicit-function-declaration]
   50 |         else if ( command == "deleteFirst") { deleteItem(null->next); size--; }
      |                                               ^~~~~~~~~~
main.c:50:62: error: request for member 'next' in something not a structure or union
   50 |         else if ( command == "deleteFirst") { deleteItem(null->next); size--; }
      |                                                              ^~
main.c:51:61: error: request for member 'prev' in something not a structure or union
   51 |         else if ( command == "deleteLast") { deleteItem(null->prev); size--; }
      |                                                             ^~
main.c: At top level:
main.c:60:1: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   60 | Item *search(int key)
      | ^~~~
      | struct 
main.c: In function 'search':
main.c:62:5: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   62 |     Item *current = null->next;
      |     ^~~~
      |     struct 
main.c:62:25: error: request for member 'next' in something not a structure or union
   62 |     Item *current = null->next;
      |                         ^~
main.c:63:39: error: request for member 'key' in something not a structure or union
   63 |     while ( current != null && current->key != key)
      |                                       ^~
main.c:65:26: error: request for member 'next' in something not a structure or union
   65 |         current = current->next;
      |                          ^~
main.c: In function 'print':
main.c:72:5: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   72 |     Item *current = null->next;
      |     ^~~~
      |     struct 
main.c:72:25: error: request for member 'next' in something not a structure or union
   72 |     Item *current = null->next;
      |                         ^~
main.c:73:25: error: request for member 'key' in something not a structure or union
   73 |     printf("%d", current->key);
      |                         ^~
main.c:78:29: error: request for member 'key' in something not a structure or union
   78 |         printf("%d", current->key);
      |                             ^~
main.c:79:26: error: request for member 'next' in something not a structure or union
   79 |         current = current->next;
      |                          ^~
main.c: At top level:
main.c:84:17: error: unknown type name 'Item'
   84 | void deleteItem(Item *m)
      |                 ^~~~
main.c: In function 'insert':
main.c:94:5: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   94 |     Item *x = (Item *)malloc(sizeof(Item));
      |     ^~~~
      |     struct 
main.c:94:16: error: 'Item' undeclared (first use in this function)
   94 |     Item *x = (Item *)malloc(sizeof(Item));
      |                ^~~~
main.c:94:22: error: expected expression before ')' token
   94 |     Item *x = (Item *)malloc(sizeof(Item));
      |                      ^
main.c:95:6: error: request for member 'key' in something not a structure or union
   95 |     x->key = key;
      |      ^~
main.c:96:6: error: request for member 'next' in something not a structure or union
   96 |     x->next = null->next;
      |      ^~
main.c:96:19: error: request for member 'next' in something not a structure or union
   96 |     x->next = null->next;
      |                   ^~
main.c:97:9: error: request for member 'next' in something not a structure or union
   97 |     null->next->prev = x;
      |         ^~
main.c:98:9: error: request for member 'next' in something not a structure or union
   98 |     null->next = x;
      |         ^~
main.c:99:6: error: request for member 'prev' in something not a structure or union
   99 |     x->prev = null;
      |      ^~