很抱歉提出这样一个新手问题,但是我怎样才能让程序读取我用我的程序输入的数据,比如 cmd 如何使用选项
shutdown.exe -f
我如何将示例 -f
读入我的程序?
最佳答案
这应该打印出传递给您的程序的每个以空格分隔的参数。
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
for(int i = 0; i < argc; i++)
{
printf("%s\n", argv[i]);
}
return 0;
}
关于C++ CMD 输入和 exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4798556/