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 deleteKey(int key);

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 { deleteKey(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 deleteKey(int key)
{
    deleteItem(search(key));
}

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:44:13: error: 'Item' undeclared (first use in this function)
   44 |     null = (Item *)malloc(sizeof(Item));
      |             ^~~~
main.c:44:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:44:19: error: expected expression before ')' token
   44 |     null = (Item *)malloc(sizeof(Item));
      |                   ^
main.c:45:9: error: request for member 'next' in something not a structure or union
   45 |     null->next = null;
      |         ^~
main.c:46:9: error: request for member 'prev' in something not a structure or union
   46 |     null->prev = null;
      |         ^~
main.c:52:47: error: implicit declaration of function 'deleteItem'; did you mean 'deleteKey'? [-Wimplicit-function-declaration]
   52 |         else if ( command == "deleteFirst") { deleteItem(null->next); size--; }
      |                                               ^~~~~~~~~~
      |                                               deleteKey
main.c:52:62: error: request for member 'next' in something not a structure or union
   52 |         else if ( command == "deleteFirst") { deleteItem(null->next); size--; }
      |                                                              ^~
main.c:53:61: error: request for member 'prev' in something not a structure or union
   53 |         else if ( command == "deleteLast") { deleteItem(null->prev); size--; }
      |                                                             ^~
main.c: At top level:
main.c:62:1: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   62 | Item *search(int key)
      | ^~~~
      | struct 
main.c: In function 'search':
main.c:64:5: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   64 |     Item *current = null->next;
      |     ^~~~
      |     struct 
main.c:64:25: error: request for member 'next' in something not a structure or union
   64 |     Item *current = null->next;
      |                         ^~
main.c:65:39: error: request for member 'key' in something not a structure or union
   65 |     while ( current != null && current->key != key)
      |                                       ^~
main.c:67:26: error: request for member 'next' in something not a structure or union
   67 |         current = current->next;
      |                          ^~
main.c: In function 'print':
main.c:74:5: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
   74 |     Item *current = null->next;
      |     ^~~~
      |     struct 
main.c:74:25: error: request for member 'next' in something not a structure or union
   74 |     Item *current = null->next;
      |                         ^~
main.c:75:25: error: request for member 'key' in something not a structure or union
   75 |     printf("%d", current->key);
      |                         ^~
main.c:80:29: error: request for member 'key' in something not a structure or union
   80 |         printf("%d", current->key);
      |                             ^~
main.c:81:26: error: request for member 'next' in something not a structure or union
   81 |         current = current->next;
      |                          ^~
main.c: At top level:
main.c:86:17: error: unknown type name 'Item'
   86 | void deleteItem(Item *m)
      |                 ^~~~
main.c: In function 'insert':
main.c:101:5: error: unknown type name 'Item'; use 'struct' keyword to refer to the type
  101 |     Item *x = (Item *)malloc(sizeof(Item));
      |     ^~~~
      |     struct 
main.c:101:16: error: 'Item' undeclared (first use in this function)
  101 |     Item *x = (Item *)malloc(sizeof(Item));
      |                ^~~~
main.c:101:22: error: expected expression before ')' token
  101 |     Item *x = (Item *)malloc(sizeof(Item));
      |                      ^
main.c:102:6: error: request for member 'key' in something not a structure or union
  102 |     x->key = key;
      |      ^~
main.c:103:6: error: request for member 'next' in something not a structure or union
  103 |     x->next = null->next;
      |      ^~
main.c:103:19: error: request for member 'next' in something not a structure or union
  103 |     x->next = null->next;
      |                   ^~
main.c:104:9: error: request for member 'next' in something not a structure or union
  104 |     null->next->prev = x;
      |         ^~
main.c:105:9: error: request for member 'next' in something not a structure or union
  105 |     null->next = x;
      |         ^~
main.c:106:6: error: request for member 'prev' in something not a structure or union
  106 |     x->prev = null;
      |      ^~