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
Expand|Select|Wrap|Line Numbers
- #include "linker.h"
- int main()
- {
- SetText();
- RunProgram();
- return 0;
- }
Expand|Select|Wrap|Line Numbers
- #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
Expand|Select|Wrap|Line Numbers
- #include <windows.h>
- #include <iostream>
- #include <cstdlib>
- #include <stdlib.h>
- using namespace std;
- #ifndef linker_h
- #define linker_h
- void RunProgram();
- void SetText();
- #endif