title: How to remove spaces from date time string in c
body: <p>The code below creates a string with date and time for example <code>Wed Jul 26 14:45:28 2017</code> </p>
  
  <p>How could I remove the spaces from it? So that is is <code>WedJul2614:45:28</code>?</p>
  
  <p>Original code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  
  int main() {
      time_t t = time(NULL);
      struct tm *tm = localtime(&amp;t);
      char s[64];
      strftime(s, sizeof(s), "%c", tm);
      printf("%s\n", s);
  }
  </code></pre>
  
  <p>I tried this code but it prints <code>wed?July</code></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  
  int main() {
      time_t t = time(NULL);
      struct tm *tm = localtime(&amp;t);
      char s[64];
      char temp[64];
      strftime(s, sizeof(s), "%c", tm);
      printf("%s\n", s);
  
  
      for (int i = 0; i &lt; sizeof(s); i++) {
        if (s[i] != ' ') {
          temp[i] = s[i];
        }
      }
  printf("%s\n", temp);  
  }
  </code></pre>