system() standard library function invokes the host operating system's command processing facility. For Windows this is essentially the console you get when running
cmd.exe which lets you run DOS-like commands such as
cls to clear the screen. Other than the function's existence, everything about
system() is platform-specific.
If you're using Xcode, you're using a Mac, which means you have Terminal.app or similar, which will use some shell (bash, by default).
clear is the program for most *nix environments to clear the screen. However, when running the program under Xcode's debugger, the
TERM environment variable isn't set and the
clear program won't know what to do. So it won't clear anything, even though the program would if you ran it directly from the terminal.
clear program does, generally, is either print a bunch of newlines or print a bunch of ANSI escape codes to manipulate the cursor and write over the console output buffer. You could do the same; the newlines in particular would be easy enough.
As for your second question: Most games don't use terminals for their main interface and so have no need to clear the terminal. Even games that do, like Nethack, use libraries like
ncurses to interact with lower-level terminal APIs and "draw" to the terminal. If that's what you're going for you should investigate those sorts of third-party libraries.
Most games use the underlying OS APIs to create windows and draw into those using platform-appropriate APIs.