c - 修改此程序以使用 getCommandLine()

标签 c windows

我有这个程序

我想修改它以使用 getCommandLine() 就在 While 循环之后,打印 getCommandLine() 返回的内容。

虽然我懂编程,但我不懂 C..

如何使用 getCommandLine?

我从逻辑上知道,getCommandLine 是 Windows 的东西,我必须导入一些东西,但是任何人都可以用实际执行它的代码来回答吗?

如果有什么不同,我正在用 TCC(Tiny C 编译器)编译它

#include <stdio.h>

int main(int argc, char *argv[]) {
    int i = 0;
    while (argv[i]) {
        printf("argv[%d] = %s\n", i, argv[i]);
        i++;
    }
    return 0;
}

最佳答案

如此处记录:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683156(v=vs.85).aspx

您需要包含 <windows.h> .但我不认为它会像你认为的那样。如果您没有 argv/argc,它只会为您提供完整的命令行字符串。

您可能还会发现这篇文章有帮助:

Canonical way to parse the command line into arguments in plain C Windows API

关于c - 修改此程序以使用 getCommandLine(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8038247/

相关文章:

c - 如何在C中定义结构体数组?

python - Zope 3 + windows + MySQL - 如何在 windows 上安装 ZMySQLDA?

windows - 使程序出现在前台但不可点击

c++ - 如何在 Windows 下使用 C++ 在多个扬声器上播放声音?

c - K&R 指向函数代码的指针

C编程: strlcpy with len = 0

c - 如何从数组中删除整数循环(例如 1-2-3-1)

c - 结构中的 Void * 空间而不是 malloc

c# - 正在删除文件,但访问被拒绝

c# - 创建原始图形元素(无 Windows chrome)