On Sat, Sep 12, 2009 at 10:58 AM, yaoyansi
Thanks for your replay,Steven. But, even I quote the arguments , the result is not what i want at all. For example , the argument: --words "Hi, how are you?" is parsed to be: "Hi, and the words- how are you?"- are ingored.
I attached my code in the first email, is there any mistake in the code?
--- 09年9月12日,周六, Steven Watanabe
写道: 发件人: Steven Watanabe
主题: Re: [Boost-users] [program_options]If a parameter in the command line contains white space, how to parse it ? 收件人: boost-users@lists.boost.org 日期: 2009年9月12日,周六,上午7:33 AMDG
yaoyansi wrote:
i use boost::program_options to parse cmd line parameters.
Attachment has my code.
And here is my test: tst.exe --wav c:/Program Files/Microsoft/a.wav --words "Hi, how are you?" --d "so,\ may\ be."
the output is : wav:[c:/Program ] words:["Hi, ] d:["so,\ ] -------------------------------------------------- But, I want the result to be : wav:[c:/Program Files/Microsoft/a.wav ]
words:[Hi, how are you?]
d:[so, may be. ]
What should I do now?
You should quote arguments containing a space. I notice that you've already quoted some of the other arguments.
It has nothing to do with the code, but rather with how the operating system shell passes the arguments. You need to quote anything that has spaces. The Hi example you gave needs quotes, so does your filepath as there is a space between program and files. Quote it! It is the same as with any other console program, take a look. You are *always* supposed to quote file paths, if you are not then you are not using the console correctly.