Visual Studio 2019:抛出例外:阅读访问违规。 ** argv **是0x2

发布于 2025-02-08 00:21:18 字数 324 浏览 1 评论 0原文

我正在尝试将命令行的参数传递到我的程序中。我将其设置在属性菜单中。

当我运行以下代码时:

#include <stdio.h>

int main(const char *argv[], int argc) {
    printf("%s", *argv);
    return 0;
}

我会收到此错误:

抛出的例外:阅读访问违规。 argv 为0x2

i在两个设置中都设置为“ DEUBG X64”。有什么建议吗?

I'm trying to pass command-line arguments into my program. I have it set in the properties menu.

When I run the following code:

#include <stdio.h>

int main(const char *argv[], int argc) {
    printf("%s", *argv);
    return 0;
}

I get this error:

Exception thrown: read access violation. argv was 0x2

I have the debugger set to "Deubg x64" in both settings. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一指流沙 2025-02-15 00:21:18

main的参数不正确。他们应该是:

int main(int argc, char *argv[]) {

The arguments to main aren't in the correct order. They should be:

int main(int argc, char *argv[]) {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文