Npp exec wrongly output program
-
Hello
I use this command in npp exec:npp_save
cd “$(CURRENT_DIRECTORY)”
gcc “$(FILE_NAME)” -o $(NAME_PART)
if $(EXITCODE)!=0
exit
endif
$(NAME_PART)on this code
#include <stdio.h> int main(){ for(int i=0;i<3;i++) printf("Hello world\n"); getchar(); return 0; }
npp opens this in notepad++ console.
Problem is that executed code wait for input, and only when it is exiting, then it prints any output. -
@PaddyGorov
You may be interested in these sections of the NppExec Manual:
3.3. Do something (how-to)
4.5. Console output redirectionIn particual, they mention usage of “npp_run” or “cmd /c start /wait” to run an application in its own window.
Or, in your C program, you may use the “explicit flushing” of the output by callingfflush
.Finally, if you want technical details of why “no output may be shown until child process ends”, here you go, the point (9) explains the root of the problem:
4.8.3. Console child process workflow -
I’ve followed the tutorial on yt “Run C/C++ Application Using Notepad++” by BoostMyTool.
Sorry I can’t upload links yet.Based on it, I wrote the command. According to it such complication shouldn’t occure.
-
@PaddyGorov
Anyway, this works:npp_save cd "$(CURRENT_DIRECTORY)" gcc "$(FILE_NAME)" -o $(NAME_PART) if $(EXITCODE)!=0 exit endif cmd /c start /wait $(NAME_PART)
-
I was considering to add a FAQ to the NppExec Manual in 2017, in the times of NppExec v0.6 alpha 1.
Well, finally, it happened :)