Can you pass your code directly into gcc? For example: gcc -? 'int main(){return 0;}'
问题 Can you pass your code directly into gcc? If so what is the command line option for it? For example: g++ -? 'int main(){return 0;}' I need to know because I am using a system command and I rather not make files: system("g++ -C "+code_string+" -o run.out"); Basile Starynkevitch solution worked, however I am getting compile errors when I use newlines: echo '#include\nint main(){printf("Hello World"); return 0;}' | g++ -x c++ -Wall -o myprog /dev/stdin Edit: fixed it echo -e '#include\nint main(