如果我的程序名称是 Test.exe 使用下面的代码,我该如何正确设置我的参数?我在想我需要添加参数来检查 | 命令,但如果我使用重定向命令“>”,则不需要这样做。所以我认为我需要在 c++ 中使用 Stream 阅读器,但我不是 100% 确定如何为管道中的任意数量的行实现它:
using namespace System;
using namespace System::IO;
int main(array<System::String ^> ^args)
{
// this doesn't work with piped in text
Console::WriteLine(":::{0}:::", args[0]);
}
在命令提示符下,我输入“test a”并回车。
:::a:::
在命令提示符下,我输入“echo hello world | test”
:::hello world:::
在 Windows 命令提示符下如何实现此功能的一个示例是使用 find 命令。我正在尝试使用 Visual Studio 2012 在我的 c++/cli 程序中实现这一点。示例:“帮助查找”:
If a path is not specified, FIND searches the text typed at the prompt
or piped from another command.