--- /dev/null
+
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <time.h>
+#include <string.h>
+#include <unistd.h>
+
+#define false 0
+#define true (!false)
+#define null 0
+
+int getColumns() {
+ struct winsize terminalSize;
+ int error;
+
+ error = ioctl(1, TIOCGWINSZ, &terminalSize);
+
+ if (!error) {
+ return terminalSize.ws_col;
+ }
+ return 80;
+}
+
+int main(int argc, char** argv) {
+
+ struct tm *localTime;
+ time_t currentTime;
+ char buffer[80];
+
+ if (fork() != 0) {
+ return 0;
+ }
+
+ while (true) {
+ currentTime = time(null);
+ localTime = localtime(¤tTime);
+ strftime(buffer, 80, "%d.%m.%Y %H:%M:%S", localTime);
+ printf("%c[s", 27); /* save cursor position */
+ printf("%c[%d;%dH", 27, 1, (int) (getColumns() - strlen(buffer))); /* set cursor */
+ printf("%s", buffer);
+ printf("%c[u", 27); /* restore cursor position */
+ fflush(stdout);
+ sleep(1);
+ }
+
+}
+