0

I'm doing an alarm clock in C++ and am currently working on the program's output. The program will output the alarm time and current time on separate lines, as such:

Your alarm is set for: 12:12 AM

It is currently: 7:08:32 PM

I have the program output once per second to keep track of the current time accurately, however rather than having new lines appear once per second, I was wondering if there would be a way to keep the current time on a single line, and have that line change accordingly to make the program more readable. I'm using cout for this program. Any help would be much appreciated.

jww
  • 97,681
  • 90
  • 411
  • 885
  • Possible duplicate of [How to refresh the screen continuously and update it in real time](https://stackoverflow.com/q/18458064/608639), [Modifying text in the terminal](https://stackoverflow.com/q/6958972/608639), [Updating/Refreshing text displayed on the terminal](https://stackoverflow.com/q/23205280/608639), etc. – jww Aug 01 '18 at 23:25
  • Possible duplicate of [C++ Change Output From "cout"](https://stackoverflow.com/questions/4388628/c-change-output-from-cout) – eesiraed Aug 01 '18 at 23:26
  • 1
    Possible duplicate of [Modifying text in the terminal](https://stackoverflow.com/questions/6958972/modifying-text-in-the-terminal) – melpomene Aug 01 '18 at 23:29
  • 1
    When looking at the answers in the commented duplicates, I'd prefer the ones discussing the `ncurses` library. Disregard the answers suggesting to hard-code escape codes into your program - or even worse, suggesting `system("clear");` or `system("cls");` (seriously?!) . – Daniel Schepler Aug 02 '18 at 00:51
  • You should try using ncurses library. It's capable of continuous refresh without blinking and other cool options. – Cirrus Aug 02 '18 at 13:02

0 Answers0