I'm using Notepad++ and NppExec to begin writing c++ code, and I was wondering how I could clear the screen. I've tried system("cls") as well as some other things that many have said worked, but when I put something like this:
do {
std::cout<<"Hello";
system("cls");
} while (true);
(Obviously not including libraries required and main) It doesn't clear anything, and the hello message just gets repeated continuously. Is it impossible to clear the screen this way, or is it a problem with Notepad++? Any help would be greatly appreciated. P.S. I've also tried manual clearing functions as well as a for-loop which creates 100 new lines. All of them do nothing.
#include <iostream>
#include <thread>
void sleep_millis(unsignedint ms)
{
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}
int main()
{
std::cout << "Hello, this should stay on the screen for 2000ms\n";
std::cout << "Hello, this should stay on the screen for 2000ms\n";
std::cout << "Hello, this should stay on the screen for 2000ms\n";
std::cout << "Hello, this should stay on the screen for 2000ms\n";
sleep_millis(2000);
system("cls");
std::cout << "Now the screen has been cleared and a new msg appears.";
}
While something is working inside NppExec - in your case it's a weblogic server - all the typed commands come into that working thing (a weblogic server in your case). So when you type "cls" while the server is running, this "cls" command is processed by the server itself. And, even if the server itself clears its console by the "cls" command, NppExec can not show you this since NppExec's just "monitors" the server's console's output and shows it in NppExec's Console.
NppExec is not a console emulator. NppExec redirects the running process'es output to its Console window, and can redirect the Console window's input to the running process (with some limitations). The NppExec's Console is not a "real" console window (actually, it uses RichEdit control for text input/output), it does not provide a console screen buffer. Thus, a console application which requires a "real" console screen buffer must be run in its own console window (using NPP_RUN command).
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ......" will clear the screen, of sorts.
it isnt the cleanest thing ever, but looking at the above post, it may be all you can do.