Any way to move "Press any key to continue ..." to a new line ?
lakshits11 opened this issue · comments
I write a c++ program.
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello World, Enter a number: ";
int x;
cin>>x;
cout<<"You entered: "<<x;
return 0;
}
This is my script to compile and run it.
SET G++ = C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\g++.exe
NPP_SAVE // save current file
cd $(CURRENT_DIRECTORY) // go to directory of the current file
"$(G++)" -Wall -std=c++17 -o "$(NAME_PART)" "$(FILE_NAME)"
if $(EXITCODE) != 0 goto Done
NPP_RUN cmd /C "$(NAME_PART)" && pause
:Done
So when I execute this script and after the complete execution of program, I get this type of window:
Is there any way to move Press any key to continue... to new line after end of program like in dev-c++:
Hello World, Enter a number: 45
You entered: 45
--------------------------------
Process exited after 2.453 seconds with return value 0
Press any key to continue . . .
Actually, it is a question about C++, not about NppExec itself. Luckily, I know both :)
In your C++ program, please specify a new line explicitly:
cout<<"You entered: "<<x<<endl;
No I mean, isn't there any other way without declaring new line explicitly, like in devc++, we don't have to do so...
Oh, I see.
Actually the message "Press any key to continue" comes from cmd.exe, not from NppExec itself. So you can explicitly ask cmd.exe to print an extra new line:
NPP_RUN cmd /C "$(NAME_PART)" && echo. && pause
Another possible option is to run your program in NppExec's Console. To do this, simply remove NPP_RUN and you no more need && pause
:
cmd /C "$(NAME_PART)"