I've got a simple program, say the following:
#include <stdio.h>
int main()
{
char buf[100];
while (fgets(buf, sizeof(buf), stdin) != NULL) {
printf("You typed: %s", buf);
}
}
and I have compiled it using Emscripten:
emcc -o hello.html hello.cpp
This gives me a pretty basic Emscripten-generated web page that contains a simple window for program output. However, the fgets()
call causes a browser popup window, presumably from prompt()
. I can type things, and the results eventually get shown in the output window. This is not an ideal interactive experience.
What I would like is a more conventional "console" interface, where the user can type interactively in the terminal window to supply input to the interactive program.
I suspect the solution may lie in something like JQueryTerminal, Hyper, or Xterm.js, but I am so far unclear on how to actually connect any of those to an Emscripten-compiled program.
How can I provide a "console" interface to my Emscripten code?