c++consolemingw

How can I prevent losing double quotes in 'argv'?


I know I can do loop like this:

for (int i=1; i <= argc-1; i++) {
  cout << argv[i] << endl;
}

But this way double quotes are lost. That is, a string, "something here", is treated as one element of the args array and quotes are lost.

I know I can assume quotes if a parameter has a space inside, but quotes are always lost no matter if there is a space or not.


Solution

  • When you need the original command line, your can use the GetCommandLine() API function.