title: Get current time in C, function
body: <p>I want to get current time (without a current date) in C. The main problem is when I want to do it with functions. When I dont use them, evertyhing is just fine. Can anybody tell me, why my code shows only an hour? (take a look at the attached image). Thanks in advance.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  #include &lt;string.h&gt;
  
  char* get_time_string()
  {
      struct tm *tm;
      time_t t;
      char *str_time = (char *) malloc(100*sizeof(char));
      t = time(NULL);
      tm = localtime(&amp;t);
      strftime(str_time, sizeof(str_time), "%H:%M:%S", tm);
      return str_time;
  }
  
  int main(int argc, char **argv)
  {
      char *t = get_time_string();
      printf("%s\n", t);
      return 0;
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/y82OW.png" alt="enter image description here"></p>