?
Solved

changing whats already outputted (DOS)

Posted on 2005-03-12
6
Medium Priority
?
173 Views
Last Modified: 2012-05-05
Hi.

im trying to make a percentage written to the screen, which should be able to change from "  0%" to "100%" while running a loop.
is there a simple way to this?
0
Comment
Question by:Tai-San
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 13524071
You can use cout or printf

#include <iostream>

int Num = 0;
std::cout << Num << "%" << std::endl;
Num += 100;
std::cout << Num << "%" << std::endl;

or

#include <stdio.h>

int Num = 0;
printf("%i%%/n", Num);
Num += 100;
printf("%i%%/n", Num);
0
 
LVL 2

Author Comment

by:Tai-San
ID: 13524128
i dont think you understand my question. assume i output this:
===================================
        Processing Compute...
        - kills : 2159
        - ratio : 0.000514
        - uvert optimization performed.
        - 4196242 averaged normal calculated.
        - xxx% creating mesh

and the xxx should be able to change (like in dos setup programs) from "  0" to "100"
0
 
LVL 30

Expert Comment

by:Axter
ID: 13524141
What compiler are you using?

And is this a DOS application?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 30

Accepted Solution

by:
Axter earned 200 total points
ID: 13524156
In DOS, you can use the "\r" character to bring the line back to the beginning without moving it to the next line.

Example code:

int main()
{
      printf("\
===================================\n\
        Processing Compute...\n\
        - kills : 2159\n\
        - ratio : 0.000514\n\
        - uvert optimization performed.\n\
        - 4196242 averaged normal calculated.\n\
");

      for(int i = 1;i < 101;++i)
      {
            printf("\r        - %03i%% creating mesh", i);
            Sleep(50);
      }
0
 
LVL 2

Author Comment

by:Tai-San
ID: 13524158
im running thw Microsoft Visual C++ .NET 2002 with the compiler/linker that follows. and yes, this is a dos application
0
 
LVL 30

Expert Comment

by:Axter
ID: 13524171
>>im running thw Microsoft Visual C++ .NET 2002 with the compiler/linker that follows. and yes, this is a dos
>>application

Then the above code I posted will work.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question