Guest User

Untitled

a guest
Feb 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <malloc.h>
  3.  
  4. /* time conf */
  5. struct time_c {
  6. long *t_tick;
  7.  
  8. int *tim_min;
  9. int *tim_sec;
  10. };
  11.  
  12. struct time_c *time;
  13. static struct time_c *tm_init() {
  14. struct time_c *time;
  15. time = malloc( sizeof( struct time_c));
  16.  
  17. return (time);
  18. }
  19.  
  20. void tm_check(struct time_c *tm) {
  21.  
  22. if (&tm->t_tick == 100000000) {
  23. tm->tim_sec++;
  24. tm->t_tick= 0;
  25. }
  26.  
  27. if (&tm->tim_sec == 60) {
  28. tm->tim_min++;
  29. tm->tim_sec=0;
  30. tm->t_tick= 0;
  31. }
  32.  
  33. tm->t_tick++;
  34. }
  35.  
  36. int main(void) {
  37. printf("Application loaded.\n");
  38.  
  39. time = tm_init();
  40. while(1)
  41. {
  42. tm_check( time);
  43. printf("%s[%d]: %nmin %nsec\n", __FILE__, __LINE__,
  44. time->tim_min, time->.tim_sec);
  45.  
  46. }
  47. return 0;
  48. }
Add Comment
Please, Sign In to add comment