C++

Does anyone know how to clear the screen in MS Visual C++? I used to know, but now I forget. Can anyone tell em the header and command?

clrscr() is only possible in Turbo C++ with conio.h, I believe…

I don’t know about an offical clear screen command (I’m still learning), but the following should work (alhough it will force the next display to the bottom of the display box)…

for (int counter=0; counter<400; counter++)
cout<< endl;

That statement assumes your display header is

#include iostream.h

If you use another one, just change the line “cout<< endl;” to whatever will display a new line.

That’s the best I can do, sorry. Hope it helps!

EDIT: note that the iostream.h should have the less than, greater than signs around it, but if I display it this way it won’t show up on the post. Sorry.

Use ampersand lt; and ampersand gt; for the less than and greater than signs. Quote this text if you want to see the source: < >

The loop would clear the screen, but you really only need about 30-40 lines and it’s kinda cheating >>; If the assignment asks you to use clrscr() you’ll have to use Turbo C++.

Thanks guys, but neither will work. Bing, thanks, but I knew your way and have considered it doing it, but it isn’t effiecient and would greatly slow my program down. Not only that, but it just doesn’t work for what I’m trying to do (let the character move around the screen). Cless, thanks, I knew that way too for Borland, but it doens’t work in MS Visual. MS Visual has something like (“cls”), sort of like BASIC, however, I can’t remember the header or proper syntax. Oh well, I guess I may have to go the text adventure route.

There’s some low level console functions that let you write characters into arbitrarily parts of the buffer and read low level input events. It is more complicated than using streams. I’d just forget about the console and use sprites…

I tried what you said Cless and it didn’t work.

If you want to try making a game, look at SDL, at http://www.libsdl.org/ . It’s a low level multimedia interface that’s easy to use. You can use it to load bitmaps and draw them onto the screen. Much more appealing than a pure text based game anyway <.<

Well, yeah, clrscr() doesn’t work for Visual C++. It only works for Turbo C++.

If you’re talking about the loop, I have no idea why it wouldn’t work…

int clearscr=0;
for (clearscr=0; clearscr <=50, clearscr++)
cout << endl;

That? If that doesn’t work maybe it’s count << << endl; I’m a little fuzzy on the syntax.

Originally posted by Cless Alvein
[b]Well, yeah, clrscr() doesn’t work for Visual C++. It only works for Turbo C++.

If you’re talking about the loop, I have no idea why it wouldn’t work…

int clearscr=0;
for (clearscr=0; clearscr <=50, clearscr++)
cout << endl;

That? If that doesn’t work maybe it’s count << << endl; I’m a little fuzzy on the syntax. [/b]

It just wouldn’t work for my purposes. Not only that, but if I did do that, no matter how cool my game was, it’d be too slow to play.