Skip to content

Commit

Permalink
Rewrite with String class
Browse files Browse the repository at this point in the history
  • Loading branch information
fxzxmic authored Jan 6, 2021
1 parent a18a754 commit ec1cea6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 25 deletions.
25 changes: 0 additions & 25 deletions main.c

This file was deleted.

37 changes: 37 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stdlib.h>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
//Get program path information
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath_s(argv[0], drive, sizeof(drive), dir, sizeof(dir), fname, sizeof(fname), ext, sizeof(ext));
//Splice command
string ch_body = "";
ch_body = fname;

int count = 1;
long length = 0;
for (count; count < argc; ++count) {
string ch_tmp = " ";
ch_tmp += argv[count];
ch_body += ch_tmp;
}

string ch_head = "bash.exe -c \"";
string ch_tail = "\"";
string ch = "";
ch += ch_head;
ch += ch_body;
ch += ch_tail;
//Forward command
const char* ch_out;
ch_out = ch.c_str();
system(ch_out);

return 0;
}

0 comments on commit ec1cea6

Please sign in to comment.