Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/ioctl.h>
- #include <unistd.h>
- void fullscreen_bar(int length) {
- struct winsize w;
- ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
- int t = w.ws_col-7;
- for (int i=1;i<=length;i++){
- printf("%3d ",i);
- putchar('[');
- for (int j=0;j<t;j++){
- if (j < i*t/length) putchar('=');
- else if (j == i*t/length) putchar('>');
- else putchar(' ');
- }
- putchar(']');
- //putchar('\r');
- fflush(stdout);
- putchar('\r');
- sleep(1);
- }
- }
Advertisement