hello.. thx in advance
just want to ask something..
is there any portable functions that is equivalent to system("cls")?
a function that clears the screen? since system() is not portable..
system() is portable -- the commands it execute are not. There are no portable ways to clear the screen. You might have to do something like this, where each compiler for the target os defines one of the symbols listed in the code below.
#elif def _WINDOWS_
#elsif def _OTHER_OPERATING_SYSTEM
systgem(<put here whatever works>);
Why do you want to do that?
(In other words, unless you are writing a full-screen text application like an editor or video game, don't do that.)
Otherwise, on Windows, see Example Two
setupterm( NULL, STDOUT_FILENO, &success );
if (success <= 0) return;
putp( tigetstr( "clear" ) );
You'll need to link with one of the following (depending on your system):
If you are writing a CUI application, though, you should just use Curses directly:
Windows, DOS, OS/2, Plan 9, etchttp://pdcurses.sourceforge.net/
POSIX systems, Mac OS X, etchttp://www.gnu.org/software/ncurses/
Hope this helps.
Couldn't you just print a lot of newlines and then move the cursor to the top of the window?
You could, but that isn't portable either. And how many newlines would you print? How would you move the cursor?