The lack of the waiting is not the fault of NPP nor NppExec: it’s the way the cmd.exe works. If you were to compile your same program (whether or not thru the NppExec interface) then use Windows Start Menu > Run > "G:\C++ Projects\GettingInput.exe" or …Run > cmd.exe /C "G:\C++ Projects\GettingInput.exe", the cmd.exe window would disappear just after, unless you have something (either a second c fscanf or c++ cin or whatever they call that input stream – sorry, I’m not a c++ expert – or a system("pause") requesting the user HIT ENTER before terminating the GettingInput.exe) – unless you have that pause, the cmd.exe window will disappear.
In case you don’t know, there’s a cmd /K option that runs any arguments passed to it in a separate cmd.exe processes, and then stays at that cmd.exe’s prompt rather than exiting, which is probably what you want. (See below.)
Further debugging for you: Looking at your output, the source didn’t compile, hence the g++ fatal error. (Presumably, after the fatal error, it was running a previously-compiled version of your executable, rather than the most recent update.) Based on the error message, my guess is that it’s the smart quotes shown in your output for “GettingInput.cpp” instead of standard quotes in "GettingInput.cpp"; with proper quotes, and my source code, it works for me (see below).
For the c example I gave, to use system("pause") you also need to include stdlib.h (sorry, I hadn’t tested the system("pause")). But once I have that, it works for me as I’ve described.
The c source code I am using:
#include <stdio.h> #include <stdlib.h> main() { int d; printf("hello, world\n"); fflush(stdout); fscanf(stdin, "%d", &d); printf("goodbye(%d)\n", d); fflush(stdout); system("pause"); }Note that I flush stdout, like I mentioned yesterday, to make sure that “some of the output letters” don’t get “cut off”. When I don’t flush, some of the letters do get cut off. (That’s a “feature” of the gnu compiler; it changes auto-flush behavior when it’s going to a terminal/console vs output being piped (and it considers the NppExec framework to be a pipe).)
I used this exact NppExec script (copy/pasted from my NppExec “Execute…” dialog):
npp_save cd "$(CURRENT_DIRECTORY)" g++ "$(FILE_NAME)" -o "$(NAME_PART)" cmd /c "$(NAME_PART)"(I even used g++ instead of gcc as my compiler, even for my plain-c source; it still works, since c is valid c++ as well)
As shown, I removed the smart quotes from the NppExec script, which had somehow made it into our earlier posts, and made sure they were normal quotes.
But after that, it worked just fine in the console:
NPP_SAVE: C:\Temp\Data\npp.c CD: C:\Temp\Data Current directory: C:\Temp\Data g++ "npp.c" -o "npp" Process started >>> <<< Process finished. (Exit code 0) cmd /c "npp" Process started >>> hello, world 5 goodbye(5) Press any key to continue . . . <<< Process finished. (Exit code 0) ================ READY ================However, if you would really prefer it in the separate cmd.exe window:
npp_save cd "$(CURRENT_DIRECTORY)" g++ "$(FILE_NAME)" -o "$(NAME_PART)" npp_run cmd.exe /k "$(NAME_PART)"Running using this, my NppExec Console window shows:
NPP_SAVE: C:\Temp\Data\npp.c CD: C:\Temp\Data Current directory: C:\Temp\Data g++ "npp.c" -o "npp" Process started >>> <<< Process finished. (Exit code 0) NPP_RUN: cmd.exe /k "npp" ================ READY ================And my cmd.exe window shows
hello, world 5 goodbye(5) Press any key to continue . . . C:\Temp\Data>