cscite

Console program does not execute correctly when run from SciTE


I'm learning C from a tutorial concurrently with a general programming course. The course setup advised Windows users to use SciTE, so I did. Possibly because I have Windows 8, I had to edit the SciTE cpp.properties file to get the sample programs to run. This is what the make/go section of the properties file looks like:

ccopts=-pedantic -Os
cc=g++ $(FileNameExt) -o $(FileName).exe
ccc=gcc $(FileNameExt) -o $(FileName).exe

make.command=make
command.compile.*.c=$(ccc) -std=c99
command.build.*.c=$(make.command)
command.build.*.h=$(make.command)
command.clean.*.c=$(make.command) clean
command.clean.*.h=$(make.command) clean
command.go.*.c=$(FileName)

My problem is that I cannot get this one program to execute in SciTE. It works fine in PowerShell/cmd but if I try to execute it in SciTE, I don't get the first printout and providing input does nothing. It also never ends, even if I stop executing. I have to go into task manager and end the program. I have had this problem before, but that was because I mistyped. I don't know what I've mistyped here:

#include <stdio.h>
#include <conio.h>

int main(void)
{
    int num1;
    int num2;
    printf("Enter 2 numbers\n");
    scanf("%d%d", &num1, &num2);

    if(num1 == num2) {
        printf("they are equal\n");
    }

    if(num1 < num2) {
        printf("%d is less than %d\n", num1, num2);
        }

    if(num1 > num2) {
        printf("%d is greater than %d\n", num1, num2);
        }

    getch();
}

Solution

  • SciTE's output pane is not a regular console as you would expect - you can not ask for user input in SciTE's output pane.

    However you can perhaps make use of parameters and slightly change you script to accept parameters instead user input.

    Another option is use of other then default subsystem for go command:

    command.compile.*.c=gcc $(FileNameExt) -o $(FileName).exe
    command.go.*.c="$(FileDir)\$(FileName).exe"
    command.go.subsystem.*.c=2
    

    You can paste this block at the end of you cpp.properties if you wish to try it. Even more if you would like a Go command that compiles on the fly and executes, append this line to above block:

    command.go.needs.*.c=gcc $(FileNameExt) -o $(FileName).exe
    

    Side note: You can always terminate running SciTE program with Ctrl+Break or with "Tools > Stop executing" menu command.