Need help with the Structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BoneKeeper
    New Member
    • May 2010
    • 4

    Need help with the Structure

    Hey all,

    i faced a new problem, and i need some help.

    I wanna type a text that will be shown in the top all time while programming is running.
    I also want to have a counter who delete it's previous text but let the main text remain. i tried use system"CLS" but it clears the whoe screen and not only the values written in the RunPorgram Function

    is there possibly any commando to just clear the text that has been written in 1 function only

    Main.cpp

    Code:
     #include "linker.h"
    
    int main()
    {
            SetText();
    	RunProgram();
    	
    return 0;
    }
    Program.cpp
    Code:
    #include "linker.h"
    
    void SetText()
    {
    	
    	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    
    	SetConsoleTextAttribute(hConsole, 4);
    	std::cout << "____________________________________________________________________________" << std::endl;
    	std::cout << "----------------------------------------------------------------------------" << std::endl;
    	SetConsoleTextAttribute(hConsole, 15);
    	std::cout << " " << std::endl;
    	std::cout << "This is ment to be a space for a text who won't change" << std::endl;
    	std::cout << "This is ment to be a space for a text who won't change" << std::endl;
    	std::cout << "This is ment to be a space for a text who won't change" << std::endl;
    	std::cout << " " << std::endl;
    	std::cout << "This is ment to be a space for a text who won't change" << std::endl;
    	std::cout << " " << std::endl;
    	SetConsoleTextAttribute(hConsole, 4);
    	std::cout << "____________________________________________________________________________" << std::endl;
    	std::cout << "----------------------------------------------------------------------------" << std::endl;
    	SetConsoleTextAttribute(hConsole, 15);
    	std::cout << "" << std::endl;
    	std::cout << "" << std::endl;
    	std::cout << "" << std::endl;
    	std::cout << "" << std::endl;
    }
    void RunProgram()
    int x = 0;
    {
         do
         {
              switch (x)
    		  {
    			case x:
    				{
    
                                     x++;
    				}
    				break;
              }
    
              system("CLS");
              std::cout << "Current Value:\n" << x << std::endl;
              std::cout << "" << std::endl;
         }while (x <= 2000);
    }

    linker.h

    Code:
     #include <windows.h>
     #include <iostream>
     #include <cstdlib>
     #include <stdlib.h>
    
     using namespace std;
    
     #ifndef linker_h
     #define linker_h
     void RunProgram();
     void SetText();
     
     #endif
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    If instead of outputting an end of line character ('\n' or endl) you output a carriage return character ('\r') you can over-write the line you just output.

    However remember if the new line is short than the old line the last characters on the old line will remain on display unless you overwrite them with a space.

    Comment

    Working...