C++捕获命令行逐行输入和输出

C++ capture command line entered and output line by line

我正在编写一个 C++ 程序,我希望从命令行捕获输入。对于在命令行中输入的每个参数,都将被捕获。该程序将捕获每个命令行,直到用户输入 END。然后程序将提供输入的每个命令行参数的输出。例子:用户输入./program到运行这个程序。 ./program 被捕获。用户然后输入 test 然后捕获用户然后输入 arg 然后 END。然后程序输出

这是我找到的资源,我只是不知道如何完全实现和循环 http://www.cplusplus.com/articles/DEN36Up4/
以下是我到目前为止所拥有的,只是不确定等待 END 的 for 循环 谢谢!

#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
    std::cout << "Enter your command line \n and to stop enter END" << std::endl;
    for (int i = 0; i < count; ++i)
    {
        /* code */
    }
    // Once user types END then arguments entered in will display
    std::cout << << std::endl;
    return 0;
}

看看cin and getline

示例代码(未测试):

string command_list;

while(true) {
    string input;
    getline (cin, input);

    if(input.compare("END") == 0)
        break;
    else
        command_list.append(input);
}