1

Is there some way to run C programs interactively through Notepad++'s console where prompts for input would appear? I can't seem to get it work as expected. I can demonstrate with this bit of code-

#include <stdio.h>
int main()
{
     int number, i;

     printf("Enter a positive integer: ");
     scanf("%d",&number);

     printf("Factors of %d are: ", number);
     for(i=1; i <= number; ++i)
     {
         if (number%i == 0)
         {
             printf("%d ",i);
         }
     }
     return 0;
}

When I run this through the NppExec plugin with this script-

NPP_CONSOLE 1
E:\Documents\Notepad++Portable\tcc\tcc.exe -run $(FULL_CURRENT_PATH)

The result is I get no prompt for input. But if I go ahead and enter it anyway, the program proceeds - prints the prompt but also completes the run as seen here.

E:\Documents\Notepad++Portable\tcc\tcc.exe -run E:\Documents\Programs_C\Factors.c Process started >>>

60

Enter a positive integer: Factors of 60 are: 1 2 3 4 5 6 10 12 15 20 30 60 <<< Process finished. (Exit code 0)

================ READY ================

I can get it to work just fine through a cmd window which I can call if I make this small change-

npp_run cmd /k E:\Documents\Notepad++Portable\tcc\tcc.exe -run $(FULL_CURRENT_PATH)

Just curious if it is at all possible to get this to work through the console which would make testing small bits of code much more convenient.

Alex G
  • 807
  • 6
  • 13
  • What happens if you use a newline or flush explicitly? `printf("Enter a positive integer:\n");` – Yunnosch Sep 21 '17 at 20:41
  • Same, no luck with that one. – Alex G Sep 22 '17 at 02:43
  • Please describe in excrutiating detail what you tried. 1) Install NppExec 2) compile above code from outside Npp, using `gcc -Wall` 3) Inside Npp click the menue ... – Yunnosch Sep 22 '17 at 05:16
  • As far as the NppExec scripting goes, that's about as much as there it is to it. I can switch from the tcc to the gcc compiler but the results are the same. I've gone over the NppExec help file with a fine-toothed comb and found comments about it not being a console emulator. So that maybe seals the deal. However, I played around with my orginial npp_run script and now have this - `NPP_RUN cmd /K gcc "$(FILE_NAME)" -o "$(NAME_PART)".exe && echo | set /p dummyVar="$(NAME_PART)"|clip` – Alex G Sep 22 '17 at 18:45
  • After reading npp_exec help file in detail it notes that it is not a console emulator even though it can support interactive python. After playing around some more I now have this - `NPP_RUN cmd /K gcc "$(FILE_NAME)" -o "$(NAME_PART)".exe && echo | set /p dummyVar="$(NAME_PART)"|clip` I can paste executable from clipboard and repeatedly run from within the same windows console. – Alex G Sep 22 '17 at 18:56

0 Answers0