PDA

View Full Version : "Clear Screen" Function in C++?




steelphantom
Mar 22, 2006, 09:14 PM
Right now I'm working on a simple C++ maze program and I want to clear the screen and redraw the maze every time the user makes a move. I know on Windows there is the system("cls") function (or something like that) that does this, but I couldn't find an equivalent that will work with my compiler on OS X. I tried clrscr(); but I got an error that it wasn't declared within my header file. Do I just need to include another header file, or is there a completely different function that does this?



pknz
Mar 22, 2006, 10:34 PM
What header files do you have?
I think these are needed, not sure which one in particular...

#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>

bousozoku
Mar 22, 2006, 10:45 PM
I could swear this issue was recently discussed and resolved. Perhaps, a search of the forum would help.

steelphantom
Mar 22, 2006, 10:52 PM
I could swear this issue was recently discussed and resolved. Perhaps, a search of the forum would help.

Yep. Got it. system("clear"); should work. I didn't recall reading a thread about this before, but I just did a search, and BAM! there it was! :o

mrichmon
Mar 22, 2006, 11:36 PM
I could swear this issue was recently discussed and resolved. Perhaps, a search of the forum would help.

Yup, a couple of months back: http://forums.macrumors.com/showthread.php?t=173777