0

I have written a code which can convert any Input Integer to equlivalent LED Display. I want to pass my system's time as an Input to this Function and get an LED Display for the same.

Example: Consider these 2 Inputs:

(system time = 10:12:00)
(system time = 11:10:04)

Problem:

The Screen Output should Overwrite the Previous Output for "10:12:00" with "11:10:04" such that the application user should get a feeling of an 'Inplace' Dynamic Display.

Requesting you to please provide some hint on how to achieve this in "C" Code. (My platform is GNU/Linux)

Thanks.

Best Regards,

Sandeep Singh

Sandeep Singh
  • 4,941
  • 8
  • 36
  • 56

2 Answers2

2

The usual way is something like:

printf("\r%s", time_string);

As far as getting the time as a string, you can retrieve the time with time(), convert to local time broken down into fields with localtime, and put a format of your choice in a string with strftime.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
1

write your string and then as much backspaces ('\b') as needed to erase this string before writing another one.

Pierre
  • 34,472
  • 31
  • 113
  • 192