Language: C++

#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next, *prev;
}

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key ){
    cur = cur -> next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nix->prev = nil;
}

void printlist() {
  Node *cur = nil->next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur -> next;
}

void deleteNode(Node *t) {
  if ( t== nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

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

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, %key)
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Compiler output:
a.cc:10:6: error: expected initializer before '*' token
   10 | Node *nil;
      |      ^
a.cc: In function 'Node* listSearch(int)':
a.cc:13:15: error: 'nil' was not declared in this scope
   13 |   Node *cur = nil->next;
      |               ^~~
a.cc: In function 'void init()':
a.cc:21:3: error: 'nil' was not declared in this scope
   21 |   nil = (Node *)malloc(sizeof(Node));
      |   ^~~
a.cc:23:3: error: 'nix' was not declared in this scope; did you mean 'unix'?
   23 |   nix->prev = nil;
      |   ^~~
      |   unix
a.cc: In function 'void printlist()':
a.cc:27:15: error: 'nil' was not declared in this scope
   27 |   Node *cur = nil->next;
      |               ^~~
a.cc:36:26: error: a function-definition is not allowed here before '{' token
   36 | void deleteNode(Node *t) {
      |                          ^
a.cc:43:19: error: a function-definition is not allowed here before '{' token
   43 | void deleteFirst(){
      |                   ^
a.cc:47:19: error: a function-definition is not allowed here before '{' token
   47 | void deleteLast() {
      |                   ^
a.cc:51:25: error: a function-definition is not allowed here before '{' token
   51 | void deleteKey(int key) {
      |                         ^
a.cc:55:22: error: a function-definition is not allowed here before '{' token
   55 | void insert(int key) {
      |                      ^
a.cc:63:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   63 | int main() {
      |         ^~
a.cc:63:9: note: remove parentheses to default-initialize a variable
   63 | int main() {
      |         ^~
      |         --
a.cc:63:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:63:12: error: a function-definition is not allowed here before '{' token
   63 | int main() {
      |            ^
a.cc:87:2: error: expected '}' at end of input
   87 | }
      |  ^
a.cc:26:18: note: to match this '{'
   26 | void printlist() {
      |                  ^