Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ cout update percentage

float progress = 0.0;
while (progress < 1.0) {
    int barWidth = 70;

    std::cout << "[";
    int pos = barWidth * progress;
    for (int i = 0; i < barWidth; ++i) {
        if (i < pos) std::cout << "=";
        else if (i == pos) std::cout << ">";
        else std::cout << " ";
    }
    std::cout << "] " << int(progress * 100.0) << " %
";
    std::cout.flush();

    progress += 0.16; // for demonstration only
}
std::cout << std::endl;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #cout #update #percentage
ADD COMMENT
Topic
Name
6+1 =