Hi. Noob here just playing around with some things trying to learn. I was wondering if there is a way to print a stationary progress bar onto my console window. I tried ftell() and fseek() but that didn't work.
Output:Code:#include <stdio.h> int main(void) { long pos[11]; int i, t; pos[0] = 0; printf("["); pos[1] = ftell(stdout); /* record current position */ for (i = 2; i < 10; ++i) { putchar('-'); pos[i] = ftell(stdout); } printf("-]"); /* print progress bar */ for (i = 1, t = 10; t > 0; ++i, --t) { fseek(stdout, pos[i], SEEK_SET); putchar('='); } return 0; }
I'm trying to overwrite the dashes. [==========].[T3256@GURY GibletSearch]$ ./temp
[---------]==========
Thanks.



LinkBack URL
About LinkBacks


