• Login
Community
  • Login

Npp exec wrongly output program

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 465 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 Nov 5, 2023, 1:48 PM

    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.

    V 1 Reply Last reply Nov 5, 2023, 3:21 PM Reply Quote 1
    • V
      Vitalii Dovgan @PaddyGorov
      last edited by Nov 5, 2023, 3:21 PM

      @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 Nov 5, 2023, 4:13 PM Reply Quote 3
      • P
        PaddyGorov @Vitalii Dovgan
        last edited by PaddyGorov Nov 5, 2023, 4:14 PM Nov 5, 2023, 4:13 PM

        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.

        V 1 Reply Last reply Nov 5, 2023, 8:10 PM Reply Quote 0
        • V
          Vitalii Dovgan @PaddyGorov
          last edited by Nov 5, 2023, 8:10 PM

          @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)
          
          V 1 Reply Last reply Nov 15, 2023, 1:19 AM Reply Quote 2
          • V
            Vitalii Dovgan @Vitalii Dovgan
            last edited by Nov 15, 2023, 1:19 AM

            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