Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <malloc.h>
- /* time conf */
- struct time_c {
- long *t_tick;
- int *tim_min;
- int *tim_sec;
- };
- struct time_c *time;
- static struct time_c *tm_init() {
- struct time_c *time;
- time = malloc( sizeof( struct time_c));
- return (time);
- }
- void tm_check(struct time_c *tm) {
- if (&tm->t_tick == 100000000) {
- tm->tim_sec++;
- tm->t_tick= 0;
- }
- if (&tm->tim_sec == 60) {
- tm->tim_min++;
- tm->tim_sec=0;
- tm->t_tick= 0;
- }
- tm->t_tick++;
- }
- int main(void) {
- printf("Application loaded.\n");
- time = tm_init();
- while(1)
- {
- tm_check( time);
- printf("%s[%d]: %nmin %nsec\n", __FILE__, __LINE__,
- time->tim_min, time->.tim_sec);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment