Hey people
can someone please help me out? My project is due tomorrow. I need a universal code so i can clear the screen in visual c++ and unix. Please let me know.
I am not sure but I believe Windows has a #define somewhere. SOmething along the lines of
#ifdef WINDOWS
// command to clear screen in windows
#else
Clear(); // not sure if this is the unix command... been
// 2 years since i used a unix system for coding
#endif
I think this is the way to go. Instead of #ifdef windows , if you put a -D _UNIX in your make file and check on that instead it should go. (Once again, please keep in mind I have not worked on unix in a while and dont remember exaclty how to define things in a make file. I think the underscore is ignored with the -D but check on that please)
In Windows we can use clear() of conio.h. But for UNIX there is no console headers. So it is better to use "clear" command of UNIX system using 'system' function of stdlib.h. include the following line at header includes. #include <stdlib.h>
and use the following line where you want to clear screen. system("clear"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.