Parse string into argv/argc

前端 未结 13 873
生来不讨喜
生来不讨喜 2020-11-28 07:45

Is there a way in C to parse a piece of text and obtain values for argv and argc, as if the text had been passed to an application on the command line?

This doesn\'

13条回答
  •  遥遥无期
    2020-11-28 08:03

    Unfortunately C++ but for others which might search for this kind of library i recommend:

    ParamContainer - easy-to-use command-line parameter parser

    Really small and really easy.

    p.addParam("long-name", 'n', ParamContainer::regular, 
               "parameter description", "default_value");  
    

    programname --long-name=value

    cout << p["long-name"];
    >> value
    

    From my experience:

    • very useful and simple
    • stable on production
    • well tested (by me)

提交回复
热议问题