Menu

running C program in NPP console PROBLEM!

robel
2008-08-05
2012-11-14
  • robel

    robel - 2008-08-05

    Good Day guys,I got this problem regarding running a C program in npp console using nppexec plugin..i manage to compile(using gcc test.c -o test.exe) my C code,it works fine,can detect errors(syntax errors and the like) much more like in turbo c compiler..but the problem being is,when running(test.exe) in the NPP console,it gives you a different output.say for instance:

    #include <stdio.h>
    int main(){
      int num;
      printf("enter a number: ");
      scanf("%d",&num);
      printf("\nthe number you enter is %d",num);
      return 0;

    }

    base on the given codes above the output should be:

    enter a number:12
    the number you enter is 12

    but in nppconsole, the output is:

    (wait for you to input)
    12
    enter a number:
    the number you enter is 12

    to make the long story short,nppconsole execute first all the scanf functions before printf functions,but when running under msdos console,it works fine,it gives me the right output.
    is there something i need to configure first before compiling and running c program in NPP?
    please help me guys..

     
    • DV

      DV - 2008-08-06

      This is a known limitation. NppExec uses pipes to redirect the console input/output and, in your situation, nothing is read from the pipe until you enter something. The WinAPI function PeekNamedPipe just says there is nothing in the pipe and that's all, NppExec can not do anything with it.
      So I recommend you to use NPP_RUN to run your application in its own (console) window.
      I.e. your NppExec's script will be similar to:

      // compiling
      gcc test.c -o test.exe
      // running
      NPP_RUN test.exe

      Or, in common case, something similar to:

      // compiling current file
      gcc "$(FULL_CURRENT_PATH)" -o "$(CURRENT_DIRECTORY)\$(NAME_PART).exe"
      // running the output .exe file
      NPP_RUN "$(CURRENT_DIRECTORY)\$(NAME_PART).exe"

      For more details, open NppExec's Console and type:

      help

      and press Enter.

       
      • robel

        robel - 2008-08-08

        well thanx for that..i got this virus on my computer that every time i open dos console it will restart my computer thats why i wanted to use npp console to run my .exe file..anyways, ill just look for antivirus to solve my problem..heheh.. thank you

         
        • TanMan

          TanMan - 2008-08-09

          Although ClamWin is pretty good, it does NOT offer real-time protection. That is, the only way it can find a virus is by scanning your machine. And you've already been infected at that point.

          These free anti virus programs will provide real time protection to prevent new viruses, as well as scanning for existing viruses on your machine. They are:

          AVG: http://free.avg.com/ww.download?prd=afe
          Avast: http://files.avast.com/iavs4pro/setupeng.exe (requires free registration)

          Avast is slightly higher rated than AVG, but I've been successful at eradicating viruses (on other people's machines) with both of these.

           
        • DV

          DV - 2008-08-08

          What about ClamWin?
          http://www.clamwin.com
          Scan your whole drive and I think it will find a lot of shitty viruses.