Community
    • Login

    Npp exec wrongly output program

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 2 Posters 452 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      PaddyGorov
      last edited by

      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.

      Vitalii DovganV 1 Reply Last reply Reply Quote 1
      • Vitalii DovganV
        Vitalii Dovgan @PaddyGorov
        last edited by

        @PaddyGorov
        You may be interested in these sections of the NppExec Manual:
        3.3. Do something (how-to)
        4.5. Console output redirection

        In 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 calling fflush.

        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

        P 1 Reply Last reply Reply Quote 3
        • P
          PaddyGorov @Vitalii Dovgan
          last edited by PaddyGorov

          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.

          Vitalii DovganV 1 Reply Last reply Reply Quote 0
          • Vitalii DovganV
            Vitalii Dovgan @PaddyGorov
            last edited by

            @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)
            
            Vitalii DovganV 1 Reply Last reply Reply Quote 2
            • Vitalii DovganV
              Vitalii Dovgan @Vitalii Dovgan
              last edited by

              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 :)

              https://d0vgan.github.io/nppexec/NppExec_Manual/FAQ.html

              1 Reply Last reply Reply Quote 3
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors