main.c GCC
12 ยท compile cached between runsTab indents. Press Escape, then Tab, to move focus out of the editor. Control or Command with Enter runs the program.
C starter
Reads integers from stdin and prints their sum. Every test passes. Run it to compile it and test it inside a Faber sandbox.
The body this demo posts to /api/v1/execute for the program on screen: a build step marked cache: true, then every test as
one parallel step. stop_on_failure skips the tests when
the build fails.
{
"stop_on_failure": true,
"steps": [
{
"cmd": "gcc",
"args": [
"-std=gnu17",
"-O2",
"-Wall",
"-o",
"main",
"main.c",
"-lm"
],
"sandbox_profile": "compile_v2",
"files": {
"main.c": "#include <stdio.h>\n\n/* Reads whitespace-separated integers and prints their sum. */\nint main(void) {\n long long value, total = 0;\n while (scanf(\"%lld\", &value) == 1)\n total += value;\n printf(\"%lld\\n\", total);\n return 0;\n}\n"
},
"cache": true
},
[
{
"cmd": "./main",
"sandbox_profile": "native_v2",
"stdin": "1 2 3\n"
},
{
"cmd": "./main",
"sandbox_profile": "native_v2",
"stdin": "40 2\n"
},
{
"cmd": "./main",
"sandbox_profile": "native_v2",
"stdin": "-7 7 100\n1000\n"
},
{
"cmd": "./main",
"sandbox_profile": "native_v2",
"stdin": ""
}
]
]
}Run the program to see Faber's response here.