Thread: Help
View Single Post
Old 07-20-2005, 01:41 PM   #8 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,720
redhead is on a distinguished road
Will this give you an idear
Code:
#include <iostream>
#include <unistd.h>
int main()
{
    std::string out_bar("");
    for(int i=1; i <= 100; ++i)
    {
        if(!(i%10))
            out_bar += "#";
        std::cout << "\r" << out_bar;
        std::cout.width(20 - out_bar.size());
        std::cout << i << "%";
        std::cout.flush();
        sleep(1);
    }
    std::cout << std::endl;
    return 0;
}
The key here is the "\r" it returns the cursor to start of line, befor the writing begins, effectively overwriting the previus shown buffer on that line..

If you're looking for something like drawing windows or segments of the shown window, look at what curses.h or ncurses.h provides, but that is system specific.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote