title: Linked List: trying to change index of node
body: <pre><code>void changeIndex(FrameNode **head, int numOfFrames)
  {
      int frameIndex = 0, i = 0;
      char name[STR_LEN];
      FrameNode* curr = *head;
      FrameNode* prev = NULL;
      FrameNode* nodeToChange = NULL;
      printf("Enter the name of the frame:\n");
      fgets(name, STR_LEN, stdin);
      name[strcspn(name, "\n")] = 0;
      while (!(searchFrame(head, numOfFrames, name)))
      {
          printf("Name is not exist in the list\n Please enter another name:");
          fgets(name, STR_LEN, stdin);
          name[strcspn(name, "\n")] = 0;
      }
      printf("Enter the index of the frame:\n");
      scanf("%d", &amp;frameIndex);
      while (frameIndex &gt; numOfFrames || frameIndex &lt; 0)
      {   
          printf("Name is not exist in the list\n Please enter another name:");
          scanf("%d", &amp;frameIndex);
      }
      getchar();
      while (curr != NULL &amp;&amp; i &lt; numOfFrames)
      {
          if (strcmp(name, curr-&gt;frame-&gt;name) == 0)
          {
              nodeToChange = createFrame(head, numOfFrames, curr-&gt;frame-&gt;path, curr-&gt;frame-&gt;duration, curr-&gt;frame-&gt;name);
              numOfFrames++;
              numOfFrames = deleteFrame(head, numOfFrames, curr-&gt;frame-&gt;name);
          }
          curr = curr-&gt;next;
          i++;
      }
      curr = *head;
      i = 0;
      if (*head != NULL)
      {
          while (i != frameIndex &amp;&amp; curr-&gt;next != NULL)
          {
              prev = curr;
              curr = curr-&gt;next;
              i++;
          }
          prev-&gt;next = nodeToChange;
          nodeToChange-&gt;next = curr;
      }
      else
      {
          *head = nodeToChange;
      }
  }
  </code></pre>
  
  <p>Here I'm trying to change the index of a node by its name. I've got a node that has a struct inside.
  It throws me an error which says that <code>prev = NULL</code> even thought I init it in the 4th while (the right value is set in <code>nodeToChange</code>).</p>
  
  <p>So my question is why it is happening and how you can suggest me to fix it?</p>