Skip to content

Instantly share code, notes, and snippets.

@Chadtech
Created December 31, 2014 02:29
Show Gist options
  • Save Chadtech/2a5ed067290a1d959cea to your computer and use it in GitHub Desktop.
Save Chadtech/2a5ed067290a1d959cea to your computer and use it in GitHub Desktop.
Executing compiled C++ from Yhavascript (AKA Javascript, AKA coffeescript executable)
# cppPrac.cpp is :
###
include <iostream>
int main (int argumentCount, char * arguments[]){
std::cout << "argument Count is " << argumentCount << "\n";
std::cout << "argument 0 is " << arguments[0] << "\n";
std::cout << "argument 1 is " << arguments[1] << "\n";
std::cout << "argument 2 is " << arguments[2] << "\n";
return 0;
}
###
sys = require 'sys'
exec = require 'child_process'
exec = exec.exec
child = exec './cppPrac a b', (error, stdout, stderr) ->
console.log 'STDOUT ', stdout
console.log 'STDERR ', stderr
if error isnt null
console.log 'ERROR ', error
# output is :
# STDOUT argument Count is 3
# argument 0 is ./cppPrac
# argument 1 is a
# argument 2 is b
# STDERR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment