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:
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);
}
and the result:
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]$
As you can see, the code does print out command entered, but not exactly as it should be.

Anybody has any suggestion for me?

Thanks,

D.