Hello, World! in C
Every C book starts here for a reason: printf is the simplest possible
bridge between a running program and the outside world, and "Hello, World!"
is the smallest program that proves the whole toolchain — compiler, linker,
runtime — actually works.
The program
#include <cstdio>
int main() {
printf("Hello, World!\n");
return 0;
}
This is an ordinary C program with a real main() — no callbacks, no
plot.hpp, no SDL. The compiler backend checks whether a sample includes
plot.hpp; if it doesn't, it skips linking the plotting library and SDL
entirely and compiles just main.cpp with a plain int main() entry point,
the same way any other C compiler would. The generated page has no
<canvas> either, since there is nothing to draw. data-console-only="true"
on the widget mirrors that on the article side, so the layout doesn't reserve
space for a canvas that will never exist.
Where does printf go?
The C program runs compiled to WebAssembly, inside a sandboxed iframe — it
has no terminal to write to. Emscripten routes anything written to stdout
through a Module.print callback instead, and the compiler backend wires
that callback to forward each line to the parent page via postMessage. The
inline widget listens for those messages and renders them in the console
panel below the editor. The same path also carries stderr and
console.log/warn/error from the compiled JavaScript glue code, so it works
for more than just printf.
Try it yourself
Edit the code above and press "Compile & Run" — change the string, add a
second printf, or make it loop.
Conclusion
Not every sample needs a canvas. For code that only produces text, the
console panel is the entire output — and data-console-only keeps the
widget honest about that instead of showing an empty picture frame.