Reputation: 5191
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
Upvotes: 0
Views: 199
Reputation: 490308
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
.
Upvotes: 2
Reputation: 35276
write your string and then as much backspaces ('\b') as needed to erase this string before writing another one.
Upvotes: 1