在 Sublime text 2 ( Mac OS X ) 中运行代码 [英] Running Code in Sublime text 2 ( Mac OS X )

查看:39
本文介绍了在 Sublime text 2 ( Mac OS X ) 中运行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 sublime text 2 中运行 C 代码,我注意到 scanf 似乎被完全忽略了,尽管它在 xcode 和带有 gcc 的终端中都可以正常工作.我个人更喜欢 sublime text 的外观,有没有办法解决这个问题?

I'm trying to run C code in sublime text 2 and i've noticed that scanf seems to be completely ignored, although it works fine in both xcode and in the terminal with gcc. I personally prefer the look of sublime text, is there a way to fix this?

推荐答案

这已经在关于 SO 的几个问题中讨论过,非官方文档 目前正在更新以更清楚地说明这一点:ST2 和 ST3 都不支持直接输入在构建系统中运行的程序inside Sublime Text: C/C++ 的 scanf 和同事不起作用,Python 的 raw_input (Python 2) 或 input (Python 3)、Ruby 的 gets、Java 的Scanner 类等,这是程序的基本限制.

This has been discussed in several questions on SO, and the unofficial docs are currently being updated to more clearly state this: neither ST2 nor ST3 supports direct input to programs running within build systems inside Sublime Text: C/C++'s scanf and colleagues do not work, nor do Python's raw_input (Python 2) or input (Python 3), Ruby's gets, Java's Scanner class, etc. This is a fundamental limitation of the program.

但是,它可以通过两种方式解决.首先,您可以在终端中运行构建系统.其次,如果您使用的是解释型语言,如 JavaScript、Python、Ruby、Perl、Scheme 以及所有相关的类 Lisp 语言,如 Clojure、Erlang、Haskell、PHP、R 等,您可以查看优秀的 SublimeREPL 插件.您可以为交互式编程打开 REPL,并将程序(或其中的一部分)发送到它并与它们进行交互,就像在命令行上一样.文档位于此处.

However, it can be worked around in two ways. First, you can run your build system in a terminal. Second, if you are using an interpreted language like JavaScript, Python, Ruby, Perl, Scheme and all the associated Lisp-like languages like Clojure, Erlang, Haskell, PHP, R, etc., you can check out the excellent SublimeREPL plugin. You can open a REPL for interactive programming, and send programs (or bits of them) to it and interact with them just as on the command line. Documentation is here.

这篇关于在 Sublime text 2 ( Mac OS X ) 中运行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆