This is something you can use
- int sec = 0;
- int min = 0;
- int hour = 0;
- while(1)
- {
- sleep(1000); //delay in milliseconds
- ++sec;
- if(sec == 60)
- {
- sec = 0;
- ++min;
- if(min == 60)
- {
- min = 0;
- ++hour;
- if(hour == 24)
- {
- hour = 0;
- }
- }
- }
- display(hour, min, sec);
- }