title: Add character at given position using pointers in C
body: <p>Running into an issue with setting character at a specific position using pointers in C.</p>
  
  <p>The code is accurately placing the character in the correct position, but the current character in that position is not being moved over.</p>
  
  <p>The issue is that the current letter is being skipped over when position is found, but adding <code>*dest++ = *string</code> within the IF block when position is found causes the program to halt.</p>
  
  <p><strong>Example:</strong>
  the string is "bigmoney". Letter to add is 'X'. The position is 3.</p>
  
  <p><strong>Output should be "bigXmoney"</strong></p>
  
  <p><strong>Current output is "bigXoney"</strong> using the code below.</p>
  
  <p>Any suggestions would be appreciated. Thanks!</p>
  
  <p><strong>Updated code:</strong></p>
  
  <pre><code>void addLetter(char string[STRING_LENGTH], char letterToAdd, int pos)
  {
      // store array in pointer
      char *stringHolder = string;
      char *dest = string;
      int posCounter = 0;
  
      // loop through string while not null
      while (*stringHolder) {
          // position found, add the character
          if (posCounter == pos) {
              *dest++ = letterToAdd;
          } else {
              *dest++ = *stringHolder;
          }
  
          // increment position counter
          posCounter++;
  
          // move the pointer position
          stringHolder++;
      }
      //reset stringholder pointer;
      *dest = '\0';
  }
  </code></pre>