Jerry Van Baren wrote: > Clemens Koller wrote: [snip]
> Here is a revised command line example that autoscales to 50 dots: > > #include <stdio.h> > #include <unistd.h> > > int main(int argc, char *argv[]) > { > int k; > int cnt; > int scale; > > if(sscanf(argv[1], "%d", &cnt) != 1) { > fprintf(stderr, "sscanf() failed\n"); > return 0; > } else { > > scale = (cnt >= 50) ? cnt / 50 : 1; Oops, the above line should be: scale = (cnt >= 50) ? (cnt +49) / 50 : 1; > > #ifdef ONELINEBAR > printf("%*c\r", (cnt + scale - 1) / scale, '|'); > #else > printf("%*c\n", (cnt + scale - 1) / scale, 'v'); > #endif > fflush(stdout); > > for(k = 0; k < cnt; k++) { > if ((k % scale) == 0) { > usleep(100000); > putchar('.'); > fflush(stdout); > } > } > printf("\n"); > } > return 0; > } Forgot to test the (50*n)-1 corner case for n > 0. :-P gvb ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users