TaillookTech

モバイルアプリ開発を追っています

bash上でC言語のプログラムを即時実行

やり方

.bash_profileに以下を記入

function shellc () {
  gcc $1 -o ~/.out && ~/.out
}

試す

test.cを作成

#include <stdio.h>

int main(void) {
    printf("Hello World!\n");
    return 0;
}

bash上で実行

USER$ shellc test.c 
Hello World!