13 struct winsize terminalSize;
16 error = ioctl(1, TIOCGWINSZ, &terminalSize);
19 return terminalSize.ws_col;
24 int main(int argc, char** argv) {
36 currentTime = time(null);
37 localTime = localtime(¤tTime);
38 strftime(buffer, 80, "%d.%m.%Y %H:%M:%S", localTime);
39 printf("%c[s", 27); /* save cursor position */
40 terminalWidth = getColumns();
41 if (terminalWidth == -1) {
44 printf("%c[%d;%dH", 27, 1, (int) (terminalWidth - strlen(buffer))); /* set cursor */
46 printf("%c[u", 27); /* restore cursor position */