You can use nodejs child_process
module to pass your arguments to your C program (see here for instance).
app.js:
var test = 1;
var exec = require('child_process').exec;
exec('./test.bin '+test, function callback(error, stdout, stderr){console.log(stdout);});
test.c:
#include <stdio.h>
int main(int argc, char **argv) {
printf("value of test: %s\n", argv[1]);
return 0;
}
Assuming test.bin
is the program built from test.c
, executing the javascript file makes the compiled program display the value of test (here, "1"). Be careful the value of the variable test
is considered as a single (not empty) argument.