473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

Expand|Select|Wrap|Line Numbers
  1.  #include "linker.h"
  2.  
  3. int main()
  4. {
  5.         SetText();
  6.     RunProgram();
  7.  
  8. return 0;
  9. }
  10.  
Program.cpp
Expand|Select|Wrap|Line Numbers
  1.  
  2. #include "linker.h"
  3.  
  4. void SetText()
  5. {
  6.  
  7.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  8.  
  9.     SetConsoleTextAttribute(hConsole, 4);
  10.     std::cout << "____________________________________________________________________________" << std::endl;
  11.     std::cout << "----------------------------------------------------------------------------" << std::endl;
  12.     SetConsoleTextAttribute(hConsole, 15);
  13.     std::cout << " " << std::endl;
  14.     std::cout << "This is ment to be a space for a text who won't change" << std::endl;
  15.     std::cout << "This is ment to be a space for a text who won't change" << std::endl;
  16.     std::cout << "This is ment to be a space for a text who won't change" << std::endl;
  17.     std::cout << " " << std::endl;
  18.     std::cout << "This is ment to be a space for a text who won't change" << std::endl;
  19.     std::cout << " " << std::endl;
  20.     SetConsoleTextAttribute(hConsole, 4);
  21.     std::cout << "____________________________________________________________________________" << std::endl;
  22.     std::cout << "----------------------------------------------------------------------------" << std::endl;
  23.     SetConsoleTextAttribute(hConsole, 15);
  24.     std::cout << "" << std::endl;
  25.     std::cout << "" << std::endl;
  26.     std::cout << "" << std::endl;
  27.     std::cout << "" << std::endl;
  28. }
  29. void RunProgram()
  30. int x = 0;
  31. {
  32.      do
  33.      {
  34.           switch (x)
  35.           {
  36.             case x:
  37.                 {
  38.  
  39.                                  x++;
  40.                 }
  41.                 break;
  42.           }
  43.  
  44.           system("CLS");
  45.           std::cout << "Current Value:\n" << x << std::endl;
  46.           std::cout << "" << std::endl;
  47.      }while (x <= 2000);
  48. }
  49.  

linker.h

Expand|Select|Wrap|Line Numbers
  1.  #include <windows.h>
  2.  #include <iostream>
  3.  #include <cstdlib>
  4.  #include <stdlib.h>
  5.  
  6.  using namespace std;
  7.  
  8.  #ifndef linker_h
  9.  #define linker_h
  10.  void RunProgram();
  11.  void SetText();
  12.  
  13.  #endif
  14.  
Jun 11 '10 #1
1 1258
Banfa
9,065 Expert Mod 8TB
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.
Jun 12 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Peter Schmitz | last post by:
Hi, I want to call a C++ function in my additional DLL out of my VB.NET code. Unforunately, this function needs a structure as an argument and here's where the problems begin: This is the...
4
by: Zoran Stipanicev | last post by:
Hi! I have a code that looks some thing like this void function() { struct st1 { template<...> struct st2 {
5
by: imranzafar | last post by:
Hi! I am a beginner in C++. This is little assignment. It gives an error "Structure Require on Left Side of dot operator" Can anybody help me what went wrong in this code? #include <conio.h>...
0
by: david | last post by:
Hi all, I am new to C#, I am trying to use a 3-party dll that require me to setup my own call back routine in a structure. All is good with in C++ if caller in c++ but in C# I am lost. The dll...
3
by: pramod | last post by:
Two differenet applications (running on different OS, different compilers) are communicating thru protocol consisting of functions and arguments. Communication link can be TCP/IP, or serial port....
1
by: Falko | last post by:
Hi there, I am currently translating a VB 6.0 application to .NET and have the following problem: The data structure I need to pass to a DLL function call has a structure variable inside its...
5
by: SP | last post by:
I am writing a function to read data into a structure, but I seem to be messing up the character string in the fopen() call. When the program runs it does not open the file and fopen() returns a...
3
by: friend.05 | last post by:
I have follwoing structure definition. struct _graph_vertex { char *label; int exectime; }; struct _graph_edge {
14
by: Harry | last post by:
Good Day, Here is a structure that i am using in my code typedef struct storable_picture { PictureStructure structure; int poc;
1
by: huynhdt | last post by:
Hi, everyone. I have a file with structure as below. public struct Security { public int StockNo (2 byte); public String StockSymbol(8 byte); public String StockType(1 byte);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.