How to compile and run C in sublime text 3?

前端 未结 12 1149
生来不讨喜
生来不讨喜 2020-11-30 20:33

I would like to compile and run C program in sublime text 3 on ubuntu 14.04. Currently the program is being compiled with gcc using sublime text 3 executing a command (see b

12条回答
  •  無奈伤痛
    2020-11-30 21:27

    For a sublime build system implementing the Run menu command :

    • Go to Tools->Build System->New Build System...

    Or

    • Create a file ~/.config/sublime-text-3/Packages/User/GCC.sublime-build

    And insert this:

    {
    "shell_cmd" : "gcc $file_name -o ${file_base_name}",
    "working_dir" : "$file_path",
    "variants":
      [
        {
          "name": "Run",
          "shell_cmd": "gcc $file_name -o ${file_base_name} && ${file_path}/${file_base_name}"
        }
      ]
    }
    

    *This example uses the GCC compiler. Feel free to replace gcc with the compiler of your choice.

提交回复
热议问题