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 :)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login