2

我正在从教程中同时学习 C 和一般编程课程。课程设置建议 Windows 用户使用 SciTE,所以我这样做了。可能因为我有 Windows 8,我必须编辑 SciTE cpp.properties 文件才能运行示例程序。这是属性文件的 make/go 部分的样子:

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)

我的问题是我无法让这个程序在 SciTE 中执行。它在 PowerShell/cmd 中运行良好,但如果我尝试在 SciTE 中执行它,我不会得到第一个打印输出,并且提供输入什么也不做。即使我停止执行,它也永远不会结束。我必须进入任务管理器并结束程序。我以前也遇到过这个问题,但那是因为我打错了。我不知道我在这里打错了什么:

#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();
}
4

1 回答 1

1

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.

于 2014-09-17T15:56:58.687 回答