473,320 Members | 1,854 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,320 software developers and data experts.

system clear in c++

254 100+
i have a function that clear the screen and then display array to cout.
i compiled no error no warning, i run it, the screen really get "clear" but it does not display anything to cout, and it "clear screen" to blanks for 2 seconds, the screen return to this :



Here is my coding:
Expand|Select|Wrap|Line Numbers
  1. /* screen.h */
  2. #ifndef _SCREEN_H_
  3. #define _SCREEN_H_
  4. #include <string>
  5. #include <iostream>
  6. #include <fstream>
  7. #include <cstdlib>
  8.  
  9. #include "array2d.h"
  10.  
  11. namespace Game{
  12.     using namespace std;
  13.     class Screen{
  14.         public:
  15.         Screen(): Xsize(80) , Ysize (23), myArray (Xsize,Ysize){};
  16.  
  17.         ~Screen(){}
  18.  
  19.         /* clear the previous screen and display new screen image with Xsize Ysize */
  20.         void Paint(){
  21.  
  22.             /* clear the screen */
  23.             system("clear");
  24.  
  25.             // and then display the screen with width and height
  26.  
  27.             for(unsigned y = 0; y < Ysize; y++){
  28.                 for(unsigned x = 0; x < Xsize; x++){
  29.                     cout << myArray.Get(Xsize , Ysize);
  30.                 }
  31.             }
  32.         }
  33.  
  34.         private:
  35.         unsigned Xsize;
  36.         unsigned Ysize;
  37.         Array2D<char> myArray;
  38.         string status;
  39.  
  40.  
Expand|Select|Wrap|Line Numbers
  1. /* testgame.cpp */
  2. #include <iostream>
  3. #include <string>
  4. #include "screen.h"
  5. #include "array2d.h"
  6.  
  7. using namespace std;
  8. using namespace Game;
  9.  
  10. int main(){
  11.         Screen s;
  12.         s.Paint();
  13.  
  14.         cout << "Testing screen display..." << endl;
  15.  
  16.     return 0;
  17. }
  18.  
I insist want to use system("clear"), but i guess the problem is within the function Paint() where after system("clear"), it cannot continue to execute.

What's the problem?
Please help.
thanks.
Nicky Eng.
Dec 12 '06 #1
2 27154
DeMan
1,806 1GB
This may nopt be the source of ur prob but methinks:
cout << myArray.Get(Xsize , Ysize);

should be
cout << myArray.Get(x , y);

firstly Xsize & Ysize are probably outside the bounds of the array (because the indexing starts at 0, and secondly I assume you are trying to loop through all the elemnts in the array
Dec 12 '06 #2
nickyeng
254 100+
thanks man.

Nick
Dec 13 '06 #3

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

Similar topics

0
by: Peter | last post by:
I am just trying to learn python, to use for some fairly basic command line utilities which will run in either Windows/DOS or Linux. I cannot find a platform neutral way of manipulating the screen....
18
by: Tim Mierzejewski | last post by:
How do I clear the text from my screen, other than a bunch of \n's or endl's? Tim M.
1
by: manoj.bhosale | last post by:
Hello Friends, I am Manoj, just started learning c++ on linux. In 'C' or 'C++' program on DOS/Windows we use clrscr(); with #include<conio.h> file included. In linux conio.h file is not exist,...
5
by: A. L. | last post by:
In Python interactive mode, is there some function acting like 'clear' command in bash? Could somebody here give some advice? Thanks in advance.
9
by: /* frank */ | last post by:
I want system ("CLS") if the system is WINDOWS system ("CLEAR") is the OS is a UNIX like.
2
by: Sam | last post by:
Sorry one of those "C" type transistion questions which I could find no answer for in existing C# text books. In C, I used to use the system function call to execute programs synchronously. ...
22
by: mp | last post by:
i have a python program which attempts to call 'cls' but fails: sh: line 1: cls: command not found i tried creating an alias from cls to clear in .profile, .cshrc, and /etc/profile, but none...
8
by: REDBAIT | last post by:
Hi Guys, Am using Windows 2000 and Dev C++ to create C programs. I'm trying to use clear screen and other graphic functions such as positioning output on screen. Have seen some documents that...
1
by: Shawn Minisall | last post by:
Does anyone know how to clear the shell screen completely ? I tried import os and then os.system("clear") was said to have worked in Windows XP, but it's just bringing up another window, then it...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.