- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在学习使用 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: cannot open output file addition.exe: Permission denied collect2.exe: error: ld returned 1 exit status [Finished in 0.3s]
我想知道我是否可以在 sublime 控制台上执行交互式程序,或者我需要对我的 sublime 构建做些什么。
最佳答案
简短版本:不,您不能在 Sublime 中运行交互式程序(并与之交互)。
来自链接器的错误消息告诉您它想要创建/修改文件 addition.exe
但不允许这样做,因为操作系统(在本例中为 windows)告诉它不能。
其根本原因是 Windows 不允许您删除/修改当前正在使用的文件,在这种情况下这意味着它正在运行。
要触及问题的核心,直接在 sublime 中运行交互式程序是不可能的;或者更确切地说,您可以运行这样的程序,但控制台中的输入与您正在运行的程序之间没有任何联系。
这意味着当您运行该程序时,您无法与其交互,但它仍然坐在那里运行,等待您输入内容。然后,当您修改代码并尝试再次构建和运行它时,您会收到此处看到的错误,因为可执行文件仍在运行且无法修改。在这种情况下,您可以取消构建以停止正在运行的程序。
为了运行这样的程序,您需要在 Sublime 之外运行它,以便您可以与其交互(或使用为您执行此操作的构建系统,例如您的第一个示例)。
也可以使用 Terminus包来构建一个交互式的构建系统。自述文件包含有关如何执行此操作的文档,包括指向概述该过程的教程视频的链接。
关于c - sublime 3控制台交互程序的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42596417/
我可能遗漏了明显的,但似乎无法解决这个相当简单和典型的案例(在 Debian 或 XP 上使用 v3 build 3022,以防万一): 启动 Sublime Text 打开一个项目“myprj”,在
在 Sublime 的精神中,我知道即使您以后不将更改保存到一个文件中,也可以从上次中断的地方开始。在保存文件之前,我在sublime中打开了一个新标签,并关闭了该应用程序。升华是否将临时文件保存在计
我有两个关于 Sublime Text Editor 2 的问题。 我的第一个问题是,我在 Packages/User 文件夹中保存了几个不同的 .tmLanguage 文件(例如:Console.t
我在 Mac 上。 另外,需要注意的是,路径段为“Packages/Solarized Color Scheme/Solarized (Dark).tmTheme”的文件在文件系统上任何地方都不存在。
我正在使用第三个 Sublime 版本,我想使用这个 CSS 梳子:https://github.com/vitaligo/CSScomb.sublime-settings/blob/master/C
我正在尝试创建一个 Sublime Text 3 插件,它从 .html、.css、.js 和 .php 等文件复制代码,然后将其粘贴到 txt 文档中。 我的问题是,有时当我从包含大量代码的文档中复
使用 Anaconda IDE package 运行 Sublime Text 3在 Mac OS X 上,当我编辑 .sublime-project 文件时,由于某种原因,某些更改将在一段时间后被删
这是我的 Preferences.sublime-settings文件: { "bold_folder_labels": true, "highlight_line": true,
我正在寻找一种方法来右键单击 Windows 10 中的文件,选择“打开方式”->“Sublime Text”,然后出现一个新的 Sublime Text 窗口。 如果 Sublime 已经打开,默认
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
我根本不想要它们,更喜欢 git 命令行,但它们被添加到我的命令中,就好像它们已安装一样,即使我从未安装过 sublime merge。 有没有办法从 sublime text 命令面板中完全删除它们
我根本不想要它们,更喜欢 git 命令行,但它们被添加到我的命令中,就好像它们已安装一样,即使我从未安装过 sublime merge。 有没有办法从 sublime text 命令面板中完全删除它们
我在 Ubuntu 12.04 LTS 上。调用 sublime foo.txt 通常会在 Sublime Text 2 中打开 foo.txt。最近我安装了 Sublime Text 3 .除此之外
有没有办法在Sublime Text Build中使用Windows变量?我有一个S搭建的系统:。有没有办法在Sublime Text Build中使用Windows变量?我有一个S搭建的系统:。我会
当我在 Sublime Repl 控制台 (Python) 中输入并按回车键运行命令时,我得到了 super 烦人的自动完成接管并更改命令。 如何在 SublimeRepl 控制台中关闭此功能? 谢谢
我需要从 sublime text 2 迁移到 sublime text 3,以获得与我在 sublime text2 上安装的所有相同的配置/插件。 我安装了 sublime text 3,但它没有
Sublime Text 2 无法打开。我不断收到此错误: (Error trying to parse file: Unexpected character, expected a comma or
只是尝试在 Windows 8.1 上为我的 OpenGL 编码设置 sublime-build。 这就是我所拥有的: { "cmd": [ "gcc -o \"$file\" \"$file_bas
所以我有一个错误,当我尝试构建时,命令行显示: grunt-cli: The grunt command line interface. (v0.1.13) [Finished in 0.1s wit
我正在尝试安装 https://github.com/alek-sys/sublimetext_indentxml在 Sublime Text 3中。我读了 In Sublime Text 3 - c
我是一名优秀的程序员,十分优秀!