Hi folks,
I need to print out the command that user enters exactly as it was entered, and this seem-to-be-simple question really bothers me. I thought there should be a simple solution for that, but honestly I have not gotten it to work yet.
My code is follow:and the result:Code:// testCMD.cpp #include <iostream> #include <string> using namespace std; int main(int argc,char *argv[]) { cout << argv[0] << " "; for (int i=1;i<argc;i++) cout << argv[i] << " "; cout << endl; return(0); }As you can see, the code does print out command entered, but not exactly as it should be.Code:$ g++ testCMD.cpp -o testCMD $ ./testCMD -aCMD1 -bYES -c '--more -here' -d "-m again" ./testCMD -aCMD1 -bYES -c --more -here -d -m again [nguyenck@kcServ:/Volumes/Data/tools/test]$
Anybody has any suggestion for me?
Thanks,
D.




.
Reply With Quote