【发布时间】:2017-03-04 13:11:53
【问题描述】:
我正在学习使用 sublime3 文本编辑器编写 C 程序,我有两个不同的 sublime 版本 此构建在 CMD 控制台上输出其执行;
> {
"cmd": ["gcc", "$file_name", "-o", "${file_base_name}.exe", "&&", "start", "cmd", "/k", "$file_base_name"],
"selector": "source.c",
"working_dir": "${file_path}",
"shell": true
}
而另一个构建在 sublime 控制台上输出其执行
> {
"cmd": ["gcc", "$file_name", "-o", "$file_base_name"],
"selector": "source.c",
"working_dir": "${file_path}",
"variants":
[
{
"name": "Run",
"cmd": ["gcc","${file}", "-o", "$file_base_name", "&&", "$file_path/$file_base_name"],
"shell":true
}
]
}
我更喜欢第二个构建,但它仅在您使用它来运行非交互式程序时才有效,例如 "Hello world" 程序,当我使用它来运行像这样的简单交互式程序时它会给我错误消息:
#include <stdio.h>
#include <float.h>
// variable declaration;
int main()
{
float a,b,sum;
printf("Enter value of a\n");
// for float u use "f" instead of d
scanf("%f", &a);
printf("Enter value of b\n");
scanf("%f",&b);
sum=a+b;
printf("The sum of %f and %f = %f\n",a,b,sum);
return 0;
}
错误信息:
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: 无法打开输出文件addition.exe:权限被拒绝collect2.exe: 错误:ld 返回 1 个退出状态 [0.3s 完成]
我想知道我是否可以在 sublime 控制台上执行交互式程序,或者我需要对我的 sublime 构建做一些事情。
【问题讨论】:
标签: c mingw sublimetext3