sigh, once again:
I tested this it worked. I even used more system'sPHP Code:
#include <iostream.h>
#include <stdlib.h>
int main()
{
cout<<"Hi"<<endl;
system("PAUSE");
system("CLS");
cout<<"Hi again"<<endl;
system("PAUSE");
return 0;
}
sigh, once again:
I tested this it worked. I even used more system'sPHP Code:
#include <iostream.h>
#include <stdlib.h>
int main()
{
cout<<"Hi"<<endl;
system("PAUSE");
system("CLS");
cout<<"Hi again"<<endl;
system("PAUSE");
return 0;
}
This failed because the output buffer wans't flushed in time. Try using endl instead of \n. Also, should you c++ people be using cin.get() instead of getchar()?!Originally posted by Powerfull Army
Thank you but theres still a problem:
consider this snippet:
cout << "Hi!\n";
getchar();
system("CLS");
cout << "Hi again!\n";
You would think it say 'Hi!',then wait for a carriage return/line-feed,then clear screen,and say 'Hi again!',but it doesn't.It waits for a carriage return/line-feed,then clears screen and prints
Hi!
Hi again!
And please tell me c++ has a way to clear the screen on its own!
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Nope. This has already been explained. CLEARING THE SCREEN IS SYSTEM SPECIFIC!And please tell me c++ has a way to clear the screen on its own!
This means that depending on your operating system, it is handled different. C++ is a LANGUAGE, not a group of libraries.
You're asking "How do I say the German word for cat in English?" ... It's two different things.
Quzah.
Hope is the first step on the road to disappointment.
>why have you made such a big deal about it in previous posts?
>Just asking...
Probably because I was talking about C at the time. In C when you don't return anything from main, the value that gets returns is undefined, C++ fixes that by defaulting to a value of successful completion (usually 0) if there is no return value.
I could have possibly confused myself and thought C while talking about C++ because my compiler will complain about no return value with C++ as well. This is why my C++ examples will all have the return statement. It's not required, but I've gotten into the habit.
-Prelude
My best code is written with the delete key.
Thanks for the explanation, Prelude.
Powerfull Army, I was just kidding, that's why I included the smiley. It does work though, at least if your colums/lines match up with the values.
Truth is a malleable commodity - Dick Cheney
ok stick one clrscr(); at the top of it before hi! and then one after the getch(); and that should work 100% properly if it doesn't ill give ou another suggestion that should work.
Simple Programming
:::: Error Message != A Smile ::::
Why not just write a routine to clear the screen in assembly? It should be easy enought to look up the right interrupt in Ralph Brown's interrupt list.
Or use a library like curses that at least exists for a number of platforms. It is likely the closest you will get to portability in this respect.
"Queen and huntress, chaste and fair,
Now the sun is laid to sleep,
Seated in thy silver chair,
State in wonted manner keep."
Most Full blown apps aren't on the command line, they are graphical in some way. C++ is a core language, as others have pointed out, so writing specific stuff will always be done in more than one line of code. If you want to write a windows app it will be many lines just to set up your window there is no MagicShowWindow. As you learn C++ you'll find places that there are very common tasks that need to be performed.. that is what functions are for. I learned all this from experience.. I remember 2 years ago when I picked up my first book on C learned all the basic syntax in a few days, and I was like "Oh, that's nice.. how do I make graphics?"I know people make full-blown applications with c++ all the time so theres got to be a simple way to clear the screen
Don't get frustrated if you have to download a library or learn some new functions or even write some of your own, that is a major part of programming, and you'll get used to it
That's a nice way of doing itOriginally posted by salvelinus
It sure does. Try this:
That should do it.PHP Code:
for (int i = 0; i < 25; i++)
{
for (int j = 0; j < 80; j++)
cout << " ";
}
But it may not work if the screen is set in a different modes
(right click on the console window's "button" on task
bar - properties - fonts.... see ? there're many options there)
Last edited by moonwalker; 08-21-2002 at 08:00 PM.
god your disgusting. only extreme nerds do thatOriginally posted by Unregistered
Why not just write a routine to clear the screen in assembly? It should be easy enought to look up the right interrupt in Ralph Brown's interrupt list.
A) Xterria, get a freaking life.
B) Interrupts are not allowed in win2k I believe (not too sure b/c I don't have it). So even that wouldn't be portable.
Edit: fixed typo
GRRR! A clear screen question.
* C'mon boys, get your flame-cannons ready. Its huntin' season... *
> Its huntin' season... *
How about not - this thread's 2 months old.
-Govtcheez
[email protected]