C言語
C言語で標準出力/入力を必要としない外部コマンド実行を行う
標準入力や標準出力の結果などを必要としない、外部コマンドを実行します。この例では、Linux上のtouchコマンドで、"panda.txt"というファイルを生成するコマンドをc言語からsystem関数を使って実行する例を示しています。
command.c
#include <stdlib.h>
int main(void) {
system("touch panda.txt");
// Please write error handling as needed
return 0;
}
実行結果
$ ls
command.c
$ gcc command.c -o command
$ ls
command command.c
$ ./command
$ ls
command command.c panda.txt