So as no one knows, for school I've been working on a tic tac toe game and its pretty fun! I tried doing some coding now but I look through all the code and its completely fine but I guess my home wifi is too laggy. :/
Good work Etian! Keep coding and you'll keep getting better. Also, just for quick reference, this code clears the screen:
cout << "\033[2J\033[1;1H";
@nt998302 , @etian guys please do not use that command, it is not portable and requires a video console, which not everyone is going to have. The actual name of that type of thing is escaping me at the moment, but just know that is part of a series of commands that are NOT portable and therefore unreliable. Also can be hurtful for methods like, say, output redirection, (piping, ya know all that good stuff. It will actually see that command - it won’t be invisible to it.)
@sanjaykdragon not really. It does the same exact thing as clearing the screen, just instead of sending out a possibly unknown sequence and literally erasing stuff from the screen, it will just shove that stuff upwards. Besides, I personally just find it better when I have a history of sorts of my input instead of only the current stuff. No need to memorize sequences or include unnecessary headers (this is including cstdlib or ncurses.h, don’t get me wrong)
@nt998302 did you just test it? the thing with system("anything") is that it has completely undefined behavior, so you never really know what you’re going to get and it can be a big security risk apparently, but don’t ask me about that because I’ve just heard that around, I don’t really know how it’s a big security risk.
@etian maybe. Not necessarily though. Don’t scare your self with strange words, most of it is quite simple.
an ansi escape code is basically anything that starts with '\e['. All it is is if you have a 'terminal emulator' or a 'video terminal', it interprets the stuff after '\e[' as a special command that is has to execute that does something. That thing can be changing the color of the text or changing the position of the cursor in the terminal or clearing the console... all sorts of things, and they all have to do with manipulation of the console screen.
system() is a function defined in the standard c library header (stdlib.h or cstdlib) and all it does is take your string that you pass it and send it as a command to the ... command processor? Idk, all I know is that it produces undefined behavior and that for repl.it it can take bash commands, so maybe command processor just means the shell?
When I say curses, I am referring to a group of header files (ncurses.h,curses.h,pcurses) that we’re created to provide a level of abstraction to manipulating the console and a certain level of portability.
system("CLEAR"); on some systems (hah) will clear the console.