2

In this question I learned how to use Sublime Text 2 to compile a C program:

How to compile and run a simple C program with Sublime Text 2?

How do I also make the program run from within Sublime Text 2?

Community
  • 1
  • 1
luoyangylh
  • 31
  • 1
  • 5
  • 1
    I didnt downvote, but whats wrong with running a shell in a separate window and pressing up, enter? Either way its probably got something to do with your PATH/compiler. – Preet Kukreti Aug 10 '12 at 04:20
  • This might be of use: http://www.quora.com/How-can-I-run-C-code-from-inside-Sublime-Text-2 – Blender Aug 10 '12 at 04:26

1 Answers1

3

Edit your build file to add the command that runs the program. You can see the output of the program in the ST console by hitting ctrl+~.

    {
      "cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe", "&&", "${file_base_name}.exe"],
      "selector" : "source.c",
      "shell" : true,
      "working_dir" : "$file_path"
    }

As an alternative, you could make a shell script or Makefile that compiles and runs the file and then call the script or make from the ST build command.

Matt York
  • 15,981
  • 7
  • 47
  • 51