Created
January 10, 2013 02:36
-
-
Save pH200/4498930 to your computer and use it in GitHub Desktop.
C execute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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