Mimicking the shell argument parser in C++

前端 未结 2 1652
故里飘歌
故里飘歌 2021-01-06 06:31

I have been working on a program that mimics a shell terminal, and I\'ve come across an implementation issue that is harder than I anticipated. Basically, I\'m trying to spl

2条回答
  •  有刺的猬
    2021-01-06 07:11

    Just passing the whole string to the shell might suit your needs:

    eg:

    System("./foo some arguments");
    

    This isn't the best solution though.

    The better way seems to be write a parser to find each argument and pass it to a exec style function.

提交回复
热议问题