在 Linux 盒子上
是否必须将程序写入文件并编译
这不能从命令行完成吗
localhost$gcc "include<stdio.h> int main(){printf('hello world'); return o; }"
当然可以,但我怀疑这是否有意义......
$ echo '#include <stdio.h>
int main() { printf("hello world\n"); return 0; }' | gcc -x c -
$ ./a.out
hello world
$
海湾合作委员会选项:
-o <file> Place the output into <file>
-x <language> Specify the language of the following input files
Permissible languages include: c c++ assembler none
'none' means revert to the default behavior of
guessing the language based on the file's extension
我一直喜欢巴里·布朗对 FizzBuzz 的回答:
在C中:
F
编译:
gcc -DF='main(){int i;for(i=0;i<101;puts(i++%5?"":"Buzz"))printf(i%3?i%5?"%d":"":"Fizz",i);}' fizzbuzz.c