C++ CMD 输入和 exe

标签 c++ input cmd user-input

很抱歉提出这样一个新手问题,但是我怎样才能让程序读取我用我的程序输入的数据,比如 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/

相关文章:

c++ - 错误 : expression must have a class type

c++ - OpenGL 绘制多个对象

html - GML 存储用户输入

windows - 如何测试路径是 Windows 批处理文件中的文件还是目录?

c++ - 如何在 C++ 中执行集合操作?

c++ - 如何修复错误 "was not declared in this scope"?

java - 将 inputListener 添加到纹理

C++;使用字符串 getline() 不适用于文件输入

batch-file - 使用 youtube-dl 下载视频并使用 FFmpeg 转换的批处理脚本

java - 以管理员身份执行Java程序