title: Debug Warning: String is not null terminated. Any idea what could it be?
body: <p>I am concatenating several strings. When running the program it gives me a Debug Assertion Failed! message which says Expression: (L"String is not null terminated" &amp;&amp; 0).</p>
  
  <p>All strings seem to be NULL terminated, but I am not sure what else could it be. Any ideas?</p>
  
  <p>I am including the code excerpt where it triggers the problem.</p>
  
  <pre><code>void foo(){
      ....
      char adj_command_string[COMMAND_SIZE];
      reconstructCommand(&amp;command_parameters, adj_command_string);
      ....
  }
  
  
  void reconstructCommand(command* command_data, char* adjusted_string){
  
      char partial_string[COMMAND_SIZE];
      char string_rep[COMMAND_SIZE];
  
      if (command_data-&gt;g_code.new_value){
          sprintf_s(string_rep, COMMAND_SIZE, "G%d ", command_data-&gt;g_code.value);
          strcat_s(partial_string, COMMAND_SIZE, string_rep);
      }
  
      // If position changed, include change in command.
      if (command_data-&gt;pos.X.value){
          sprintf_s(string_rep, COMMAND_SIZE, "X%.4f ", command_data-&gt;pos.X.value);
          strcat_s(partial_string, COMMAND_SIZE, string_rep);
      }
  
      if (command_data-&gt;pos.Y.value){
          sprintf_s(string_rep, COMMAND_SIZE, "Y%.4f ", command_data-&gt;pos.Y.value);
          strcat_s(partial_string, COMMAND_SIZE, string_rep);
      }
  
      if (command_data-&gt;pos.Z.value){
          sprintf_s(string_rep, COMMAND_SIZE, "Z%.4f ", command_data-&gt;pos.Z.value);
          strcat_s(partial_string, COMMAND_SIZE, string_rep);
      }
  
      if (command_data-&gt;pos.A.value){
          sprintf_s(string_rep, COMMAND_SIZE, "A%.4f ", command_data-&gt;pos.A.value);
          strcat_s(partial_string, COMMAND_SIZE, string_rep);
      }
  
      // If Feedrate originally included, include it in modified command
      if (command_data-&gt;feedrate.new_value){
          sprintf_s(string_rep, COMMAND_SIZE, "F%.4f ", command_data-&gt;feedrate.value);
          strcat_s(partial_string, COMMAND_SIZE, string_rep);
      }
  
      // If spindle speed originally included, include it in modified command
      if (command_data-&gt;speed.new_value){
          sprintf_s(string_rep, COMMAND_SIZE, "S%.4f ", command_data-&gt;speed.value);
          strcat_s(partial_string, COMMAND_SIZE, string_rep);
      }
  
      adjusted_string = partial_string;
  }
  </code></pre>