-1

hello
i m doing c project on digital clock.
i dont where do i start from
i m not so confident

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
0

If you want to display something on the same line of the screen as a previous instance, such as time, then just use '\r' to move the cursor back to the beginning of the first line. It does something similary to when you press the Backspace key on the keyboard.

#include <stdio.,h>
#include <windows.h> // assumes MS-Windows operating system
int main()
{
    int counter = 0;
   int i;
   for(i = 0; i < 1000; i++)
  {
      printf("\r%d", counter;
     counter++;
     Sleep(1000); // 1 second pause
  }
  return 0;
}

The above just displays the value of a counter, so you will have to modify the program to display the time (hours:minutes:seconds).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.