Reputation: 21
I am making a Library Management System in Xcode using C++. As Xcode does not support libraries such as conio.h and system "cls" does not work in it. What code should I use to clear the screen when I want it to shift from one menu to the other?
Upvotes: 2
Views: 15754
Reputation: 21
Check this out.
https://discussions.apple.com/thread/1064635?start=0&tstart=0
There is no direct way to do that; the system()
command will not work on Mac (Unix). One option is to add a lot of spaces using code i.e.\n or other way is to use curses library
#include < curses.h >
(curses.h) and then use system("clear")
, which basically will do the same thing. So, its better to print spaces manually using the code rather than using some library.
One more thing you can do for POSIX (Unix, Linux, Mac OSX, etc) based systems [Note: I have not tested it myself]:
#include < unistd.h >
#include < term.h >
void ClearScreen()
{
if (!cur_term)
{
int result;
setupterm( NULL, STDOUT_FILENO, &result );
if (result <= 0) return;
}
putp( tigetstr( "clear" ) );
}
You'll have to link to the proper library (one of -lcurses
, -lterminfo
, etc.) to compile that last one. (Source: http://www.cplusplus.com/forum/articles/10515/)
Upvotes: 2