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?
Asked
Active
Viewed 1.5k times
2
-
are you talking about a command line application (that you just write and launch from within Xcode)? Or a Xcode-plugin? Your question is not very clear, to me at least. – Matthias Bauch Feb 19 '12 at 09:54
-
1@Nishay: `man system` says "#include
". `man` is what we used before there were stackoverflows and googles on the internets, and it still works. – molbdnilo Feb 19 '12 at 11:52
1 Answers
2
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/)

Mechanical snail
- 29,755
- 14
- 88
- 113

kamran
- 21
- 3