Language: C

#include<stdio.h>
 
struct{
    int key;
    struct node *next;
    struct node *prev;
    } typedef Node pointer;

NodePointer finditem(int);
void print(void);
NodePointer make_1node(int,NodePointer);
void deleteFirst(void);
void deleteLast(void);
void deleteNode(NodePointer);
NodePointer head;
 
int main(){
    int key, n, i;
  int size = 0;
  char order[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", order, &key);
    if ( order[0] == 'i' ) {insert(key); np++; size++;}
    else if ( order[0] == 'd' ) {
      if (strlen(order) > 6){
    if ( order[6] == 'F' ) deleteFirst();
    else if ( order[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++;
      }
      size--;
    }
  }
    
  print();
  return 0;
}
 
NodePointer finditem(int key){
  NodePointer x;
  x = head->next;
  while(x != head && x->key != key){
    x = x->next;
  }
  return x;
}
 
void insert(int key){
  NodePointer y;
  y = malloc(sizeof(struct node));
  y->key = key;
  y->next = head->next;
  head->next->prev = y;
  head->next = y;
  y->prev = head;   
}
 
void print(){
  NodePointer z = head->next;
  int flag = 1;
  while(1){
    if ( z == head ) break;
    if ( flag == 0)  printf(" ");
    printf("%d", z->key);
    z = z->next;
    flag = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer del){
  del->prev->next = del->next;
  del->next->prev = del->prev;
  free(del);
}
  
void deleteFirst(){
  NodePointer del_f = head->next;
  if ( del_f == head ) return;
  deleteNode(del_f);
}
  
void deleteLast(){
  NodePointer del_l = head->prev;
  if ( del_l == head ) return;
  deleteNode(del_l);
}
  
void delete(int key){
  NodePointer del;
  del = finditem(key);
  if(del == head) return;
    
  deleteNode(del);
    
}
void init(){
  head = malloc(sizeof(struct node));
  head->next = head;
  head->prev = head;
}

Compiler output:
main.c:7:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pointer'
    7 |     } typedef Node pointer;
      |                    ^~~~~~~
main.c:9:1: error: unknown type name 'NodePointer'
    9 | NodePointer finditem(int);
      | ^~~~~~~~~~~
main.c:11:1: error: unknown type name 'NodePointer'
   11 | NodePointer make_1node(int,NodePointer);
      | ^~~~~~~~~~~
main.c:11:28: error: unknown type name 'NodePointer'
   11 | NodePointer make_1node(int,NodePointer);
      |                            ^~~~~~~~~~~
main.c:14:1: error: parameter names (without types) in function declaration [-Wdeclaration-missing-parameter-type]
   14 | void deleteNode(NodePointer);
      | ^~~~
main.c:15:1: error: unknown type name 'NodePointer'
   15 | NodePointer head;
      | ^~~~~~~~~~~
main.c: In function 'main':
main.c:23:3: error: implicit declaration of function 'init' [-Wimplicit-function-declaration]
   23 |   init();
      |   ^~~~
main.c:26:29: error: implicit declaration of function 'insert' [-Wimplicit-function-declaration]
   26 |     if ( order[0] == 'i' ) {insert(key); np++; size++;}
      |                             ^~~~~~
main.c:28:11: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
   28 |       if (strlen(order) > 6){
      |           ^~~~~~
main.c:2:1: note: include '<string.h>' or provide a declaration of 'strlen'
    1 | #include<stdio.h>
  +++ |+#include <string.h>
    2 | 
main.c:28:11: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
   28 |       if (strlen(order) > 6){
      |           ^~~~~~
main.c:28:11: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:32:5: error: implicit declaration of function 'delete'; did you mean 'deleteNode'? [-Wimplicit-function-declaration]
   32 |     delete(key); nd++;
      |     ^~~~~~
      |     deleteNode
main.c: At top level:
main.c:42:1: error: unknown type name 'NodePointer'
   42 | NodePointer finditem(int key){
      | ^~~~~~~~~~~
main.c: In function 'finditem':
main.c:43:3: error: unknown type name 'NodePointer'
   43 |   NodePointer x;
      |   ^~~~~~~~~~~
main.c:44:11: error: invalid type argument of '->' (have 'int')
   44 |   x = head->next;
      |           ^~
main.c:45:23: error: invalid type argument of '->' (have 'int')
   45 |   while(x != head && x->key != key){
      |                       ^~
main.c:46:10: error: invalid type argument of '->' (have 'int')
   46 |     x = x->next;
      |          ^~
main.c: At top level:
main.c:51:6: warning: conflicting types for 'insert'; have 'void(int)'
   51 | void insert(int key){
      |      ^~~~~~
main.c:26:29: note: previous implicit declaration of 'insert' with type 'void(int)'
   26 |     if ( order[0] == 'i' ) {insert(key); np++; size++;}
      |                             ^~~~~~
main.c: In function 'insert':
main.c:52:3: error: unknown type name 'NodePointer'
   52 |   NodePointer y;
      |   ^~~~~~~~~~~
main.c:53:7: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   53 |   y = malloc(sizeof(struct node));
      |       ^~~~~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    1 | #include<stdio.h>
  +++ |+#include <stdlib.h>
    2 | 
main.c:53:7: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   53 |   y = malloc(sizeof(struct node));
      |       ^~~~~~
main.c:53:7: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:53:21: error: invalid application of 'sizeof' to incomplete type 'struct node'
   53 |   y = malloc(sizeof(struct node));
      |                     ^~~~~~
main.c:54:4: error: invalid type argument of '->' (have 'int')
   54 |   y->key = key;
      |    ^~
main.c:55:4: error: invalid type argument of '->' (have 'int')
   55 |   y->next = head->next;
      |    ^~
main.c:55:17: error: invalid type argument of '->' (have 'int')
   55 |   y->next = head->next;
      |                 ^~
main.c:56:7: error: invalid type argument of '->' (have 'int')
   56 |   head->next->prev = y;
      |       ^~
main.c:57:7: error: invalid type argument of '->' (have 'int')
   57 |   head->next = y;
      |       ^~
main.c:58:4: error: invalid type argument of '->' (have 'int')
   58 |   y->prev = head;
      |    ^~
main.c: In function 'print':
main.c:62:3: error: unknown type name 'NodePointer'
   62 |   NodePointer z = head->next;
      |   ^~~~~~~~~~~
main.c:62:23: error: invalid type argument of '->' (have 'int')
   62 |   NodePointer z = head->next;
      |                       ^~
main.c:67:19: error: invalid type argument of '->' (have 'int')
   67 |     printf("%d", z->key);
      |                   ^~
main.c:68:10: error: invalid type argument of '->' (have 'int')
   68 |     z = z->next;
      |          ^~
main.c: At top level:
main.c:74:17: error: unknown type name 'NodePointer'
   74 | void deleteNode(NodePointer del){
      |                 ^~~~~~~~~~~
main.c: In function 'deleteFirst':
main.c:81:3: error: unknown type name 'NodePointer'
   81 |   NodePointer del_f = head->next;
      |   ^~~~~~~~~~~
main.c:81:27: error: invalid type argument of '->' (have 'int')
   81 |   NodePointer del_f = head->next;
      |                           ^~
main.c: In function 'deleteLast':
main.c:87:3: error: unknown type name 'NodePointer'
   87 |   NodePointer del_l = head->prev;
      |   ^~~~~~~~~~~
main.c:87:27: error: invalid type argument of '->' (have 'int')
   87 |   NodePointer del_l = head->prev;
      |                           ^~
main.c: At top level:
main.c:92:6: warning: conflicting types for 'delete'; have 'void(int)'
   92 | void delete(int key){
      |      ^~~~~~
main.c:32:5: note: previous implicit declaration of 'delete' with type 'void(int)'
   32 |     delete(key); nd++;
      |     ^~~~~~
main.c: In function 'delete':
main.c:93:3: error: unknown type name 'NodePointer'
   93 |   NodePointer del;
      |   ^~~~~~~~~~~
main.c: At top level:
main.c:100:6: warning: conflicting types for 'init'; have 'void()'
  100 | void init(){
      |      ^~~~
main.c:23:3: note: previous implicit declaration of 'init' with type 'void()'
   23 |   init();
      |   ^~~~
main.c: In function 'init':
main.c:101:10: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
  101 |   head = malloc(sizeof(struct node));
      |          ^~~~~~
main.c:101:10: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:101:24: error: invalid application of 'sizeof' to incomplete type 'struct node'
  101 |   head = malloc(sizeof(struct node));
      |                        ^~~~~~
main.c:102:7: error: invalid type argument of '->' (have 'int')
  102 |   head->next = head;
      |       ^~
main.c:103:7: error: invalid type argument of '->' (have 'int')
  103 |   head->prev = head;
      |       ^~