Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indica
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
✍: Guest
These simple things, at least, you can do fairly portably. Printing the character '\r' will usually give you a carriage return without a line feed, so that you can overwrite the current line. The character '\b' is a backspace, and will usually move the cursor one position to the left.
Using these characters, you can print a percentage-done indicator:
for(i = 0; i < lotsa; i++) {
printf("\r%3d%%", (int)(100L * i / lotsa));
fflush(stdout);
do_timeconsuming_work();
}
printf("\ndone.\n");
or a baton:
printf("working: ");
for(i = 0; i < lotsa; i++) {
printf("%c\b", "|/-\"[i%4]);
fflush(stdout);
do_timeconsuming_work();
}
printf("done.\n");
2015-04-27, 1291👍, 0💬
Popular Posts:
Can a variable be both const and volatile? Yes. The const modifier means that this code cannot chang...
What's the output of the following program? And why? #include main() { typedef union { int a; char b...
What are the different accessibility levels defined in .NET ? Following are the five levels of acces...
.NET INTERVIEW QUESTIONS - What is the difference between System exceptions and Application exceptio...
How do we configure “WebGarden”? “Web garden” can be configured by using process model settings in...