title: C strcat garbage characters
body: <p>I have a function in C where i am trying to get strings from two different locations (unknown size, could be quiet large) and combine them into one string and return them. If i just print the two strings then I get the correct result, but when I try to combine the strings using strcat I end up with 5 garbage characters and then the result of the combined strings.</p>
  
  <p>Anyone have some advice as to what I am doing wrong? Here is some sample code to demonstrate what I am doing:</p>
  
  <pre><code>static int get_information(char** results)
  {
      size_t s1_length;
      size_t s2_length;
  
      /* DEBUGGING - Prints the correct string */
      printf(get_string_1());
      printf(get_string_2());
      printf("\n");
  
      /* Allocate memory for new string */
      s1_length = strlen(get_string_1());
      s2_length = strlen(get_string_2());
      *results = malloc(sizeof(char) * (dir_length + file_length));
  
      if(results == NULL)
          return -1;
  
      /* Combine the strings */
      strcat(*results, get_string_1());
      strcat(*results, get_string_2());
  
      /* DEBUGGING - prints 5 garbage characters then the correct string */   
      printf(*results);
      printf("\n");
  
      return 0;
  }
  </code></pre>