Skip to content

Instantly share code, notes, and snippets.

@sahara-ooga
Last active December 31, 2017 11:52
Show Gist options
  • Save sahara-ooga/694fb52a7468e6d0dbdbcb0a9a217054 to your computer and use it in GitHub Desktop.
Save sahara-ooga/694fb52a7468e6d0dbdbcb0a9a217054 to your computer and use it in GitHub Desktop.
VS Code上でCのコードを動かす

VS Code上でCのコードを動かす

VS Codeの拡張機能 Runnerを使った。

ユーザ設定

    "runner.languageMap": {
        "c": "/Users/******/Documents/visual_studio_code/runner/runc_gcc.sh"
    },

キーボードショートカット

Runnerのデフォルトのキーボードショートカットは動かなかったので、 Ctrl + option + r を設定した。

file menu

keyboard setting

キーボードショートカットを押した際に走るシェルスクリプト

runc_gcc.sh

#!/bin/sh
cd ~/
clang -o a.out $1
./a.out
rm a.out

実行するCのコード

#include <stdio.h>
 
int main(void)
{
    printf("Hello, hello, hello, hello how low world! \n");
    return 0;
}

出力

Hello, hello, hello, hello how low world! 

result

参考

シェルスクリプトはここのをつかって初めて動いた。

それ以外は https://qiita.com/dockurage/items/49e7295e7ff7458e26cd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment