title: Displaying date and time in the file name
body: <p>I'm trying to create a file with the current date and time (seperated by underscores) as the file name, but I get the following error when compiling:</p>
  <pre><code>main.c:45:31: error: ‘%02d’ directive writing between 2 and 11 bytes into a region of size between 1 and 17 [-Werror=format-overflow=]
     45 |   sprintf(fileName,&quot;%04d_%02d_%02d_%02d_%02d_%02d&quot;,ptm-&gt;tm_year + 1900, ptm-&gt;tm_mon+1, ptm-&gt;tm_mday, ptm-&gt;tm_hour, ptm-&gt;tm_min,ptm-&gt;tm_sec);
  cc1: all warnings being treated as errors
  </code></pre>
  <p>How do I suppress this warning/solve this issue?</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;math.h&gt;
  #include &lt;string.h&gt;
  #include &lt;time.h&gt;
  
  int main(int argc, char *argv[]) {
    time_t rawtime;
    time(&amp;rawtime);
    struct tm * ptm = localtime(&amp;rawtime);
    char fileName[25];
    sprintf(fileName,&quot;%04d_%02d_%02d_%02d_%02d_%02d&quot;,ptm-&gt;tm_year + 1900, ptm-&gt;tm_mon+1,
      ptm-&gt;tm_mday, ptm-&gt;tm_hour, ptm-&gt;tm_min,ptm-&gt;tm_sec);
  }
  </code></pre>