Hello, 

The program I am trying to make is a simple timer. It uses the sleep function 
to calculate the appropriate amount of time. 

Initially, I developed it on Windows and everything worked fine. However when 
I came to run it on Linux, after a certain point it froze. I isolated the 
problem to just a few lines of code but i cant work out why its having 
trouble recording the current time properly. 

Any help would be greatly appreciated.

Below is the source code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

char line[100];

int flag = 0;
int i = 0;
int end_point = 10;
int begin;
int end;
int input1;
int input2;
int indicator; 

int main() {

          time_t begin;
          time(&begin);
          input1 = ctime(&begin);
          
   while (1) {
           
        ++i;
        sleep(1);
        
        printf("%d\n", i);   
  
        if (i == end_point) 
            break;
    }       
    
          time_t end;
          time(&end);
          input2 = ctime(&end);
          
          printf("%s", input1);
          printf("\n%s\n", input2);
             
    return 0;
}

Regards, Daniel








Attachment: timer
Description: application/executable

_______________________________________________
Make-w32 mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/make-w32

Reply via email to