Skip to content

Instantly share code, notes, and snippets.

@pH200
Created January 10, 2013 02:36
Show Gist options
  • Save pH200/4498930 to your computer and use it in GitHub Desktop.
Save pH200/4498930 to your computer and use it in GitHub Desktop.
C execute
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[]) {
if (argc > 1) {
char* arg = argv[1];
char cmdprefix[] = "node app.js -channel demo -url ";
char* cmd = (char*)malloc(
strlen(cmdprefix) + strlen(arg) + 1
/* \0 */
);
strcpy(cmd, cmdprefix);
strcat(cmd, arg);
system(cmd);
free(cmd);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment