All pastes #202615 Raw Edit

ai-a

public cpp v1 · immutable
#202615 ·published 2006-10-14 17:03 UTC
rendered paste body
// create a vector for each argument passed within lpCmdLine// takes into consideration any white space and quotes  vector<string> args;  string arg;  const char *p = lpCmdLine;  bool quote = false;  while (char ch = *p++) {    if (!quote && iswspace(ch) && arg.length()) {      args.push_back(arg);      arg = "";    }    else if (ch == '"')      quote = !quote;    else if (!iswspace(ch) || quote || arg.length())      arg += ch;  }  if (arg.length())    args.push_back(arg);