Deleting a node in a singly linked list? Please critique the following code on removing a node from a singly linked list, at the moment it seems to me like the code is quite clunky.
typedef struct Node {
    int data;
    struct Node* next;
}Node;

Node* create(int A[], int n){
    Node *head = malloc(sizeof(Node));
    Node *temp = NULL;
    Node *tail;
    head-&gt;data = A[0];
    head-&gt;next = NULL;
    tail = head;
    int i;
    for (i = 1; i &lt; n; i++){
        temp = malloc(sizeof(Node));
        temp-&gt;data = A[i];
        temp-&gt;next = NULL;
        tail-&gt;next = temp;
        tail = temp;
    }
    return head;
}

void delete(Node** head, int index) {
    Node* temp;
    Node* curr;
    Node* prev = NULL;
    curr = *head;
    int pos;
    if (*head == NULL) {
        return;
    }
    if (index == 0) {
        temp = curr-&gt;next;
        *head = temp;
        free(curr);
    }
    else {
        for (pos = 0; pos &lt; index; pos++) {
            prev = curr;
            curr = curr-&gt;next;
        }
        prev-&gt;next = curr-&gt;next;

        free(curr);
    }


}

int main(){
    int A[] = {3, 5, 7, 9, 10};
    Node *head = create(A, 5);
    delete(&amp;head, 1);
    return 0;
   }
Mark variables that will remain constant as const.
Initialise variables right away when they're created, if possible. You're just adding one extra line with no benefit.
Limit the scope of variables by creating them only when they're required, not at the top. They'll go unused in certain conditions. Also one won't have to sanity check the whole function to see if the variable has been modified since it was created.
Use a more descriptive function name. del_node_at_index is even better.

void delete_node(Node **head, const int index)
{
  // Initialise curr when it's defined. 
  Node *curr = *head;

  if (head == NULL) {
    return;
  }
  if (index == 0) {
    // Keep the scope of temp limited.
    // Initialise temp when it's defined.
    Node *temp = curr-&gt;next;
    *head = temp;
    free(curr);
  }
  else {
    // Keep the scope of prev limited. 
    Node *prev;
    // Define pos if and when needed.
    for (int pos = 0; pos &lt; index; pos++) { 
      prev = curr;
      curr = curr-&gt;next;
    }
    prev-&gt;next = curr-&gt;next;

    free(curr);
  }
}