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

Recommended Answers

All 2 Replies

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.