How to clear screen without using system("clear")? A solution is std::cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" << std::endl;, but I am making an encryption program, so I need to properly clear the screen.
When I use std::printf("%c[2J",27); it does like printing '\n' many times. I need to properly clear the screen, like calling clear from the terminal. (Please don't make me go into POSIX stuff, because I have no idea what is a thread and these things. Only thing I know from POSIX is if(getuid()) // then i am not sudo ).
EDIT: I googled and most solutions use (n)curses.h. I tried that, but doesn't work. I can't input any text at all.
Nope, C++ doesn't (and isn't supposed to) know what a "console" or "terminal" is. All it knows is that it has an input stream and an output stream to connect it to the outside world.
C++ wasn't made for any specific purpose. It's design allows it to take input, and produce output through stdin and stdout (cin and cout in C++). How a terminal handles this is generally to allow the user to enter a string for cin, and display anything out of cout. cin/cout can be routed to anything though: files, devices, etc...
If you programatically redirect stdout and stdin, you can have a program that takes input/ouput from a file, which is useful if you want another program to be able to "communicate" with it by sending input and recieving output.