title: add a char to a string in c
body: <p>I have this function called <code>add_to_string</code> and I call it from my main function to add a char to a string </p>
  
  <pre><code>add_to_string(name[I]);
  </code></pre>
  
  <p>it seems to me that I cannot append a char into a string. so how would I tackle this problem?</p>
  
  <p>my main intention in this code is simply to print the entered name initials and avoid the user wrong entry (adding two spaces between first name and middle name)</p>
  
  <p>here is my full code</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;cs50.h&gt;
  #include&lt;string.h&gt;
  
  string add_to_string (char letter);
  string result;
  
  int main (void) 
  {
      printf("pleas enter your full name:  ");
      string name = get_string();
      int len = strlen(name);
      for (int i = 0; i &lt; len; i++)
          {
              if (i == 0) 
              {
                  add_to_string(name[i]);
              } else if (name[i] == ' ')
              {
                  if (name[i + 1] != ' ')
                  {
                  add_to_string(name[i]);
                  }
              }
      }
  
      printf("%s\n",result);
  }
  
  string add_to_string (char letter)
  {
  
      strncat(result, letter, 30);
      return result;
  }
  </code></pre>