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
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.
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.