Have any of you ever seen an installation from the command prompt?
I will use MinGW installing g++ as an example:
When it's downloading from sourceforge, it has a little progress bar made of equals:
[==============] (or something like that)
When this bar updates itself as the packages are downloading, it doesn't change lines: it updates the bar on the same line as before so you don't have a bunch of leftover lines.
If I understand you right you're wanting kind of a progress bar made up of equal signs or whatever that adds the symbol to the line as processing proceeds.
Depending on the effect you want, it could get a little dicey with just the C Std. Lib. functions, but with the Console Functions from the Windows Api it is doable. Look up SetConsoleCursorPosition. Its difficult to use, but hey, what isn't?
Here I've used the windows header only for the Sleep() function, which is incidental. However, I don't think this code would behave the same on other platforms.
For a platform-independent solution then ncurses may be what you are looking for.
Yes, Sleep() was just to simulate some other lengthy process.
what do '\r' and the flush function do?
'\r' Is carriage return. In this case it moves the cursor back to the start of the current line.
(See also '\n' which moves the cursor down to the next line). flush may not be necessary - it was a precaution depending on the environment, sometimes the output is not displayed immediately. The output is first stored in a buffer. Flush simply forces the buffer to be emptied and its contents sent to the physical device - in this case the console.
What if I wanted to update every time a action occurred (like a command or something)?
You'd probably want to call a function each time. The function will update the console display and then return to continue whatever else the program was doing.