title: How to use seconds (time) in C program as a counter?
body: <p>I am trying to get a C program to use "seconds" from clock_t as a for loop counter. How is it possible? Below is my coding which is not working, </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include &lt;time.h&gt;
  
  int main()
  {
    clock_t begin, end;
  double time_spent;
  
  begin = clock();
  time_spent = (double)begin / CLOCKS_PER_SEC;
  
  for(time_spent=0.0; time_spent&lt;62000.0; time_spent++)
  {
      printf("hello \n");
  
      if(time_spent==5.0)
      break;
  }
  
  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  
      printf(" %lf\n", time_spent);
  }
  </code></pre>