为什么我的 Xcode 方言更改没有生效?

发布于 2025-01-17 23:55:05 字数 582 浏览 2 评论 0原文

我刚刚开始接触 C 语言中的字符串,我的老师在 Windows 上使用 CodeBlocks,而我正在使用 Xcode。 他向我介绍了这一点:

#include <stdio.h>
#include <string.h>
int main()
{
    char name[15];
    printf("Enter your name ");
    scanf("%[^\n]s\n",&name);
    printf("Welcome, %s !",name);
    size_t a=strlen(name);
    printf("Your name is %zu\n",a);
    strupr(name);
    printf("\n")
}

但是当我在 Xcode 中执行相同的程序时,strupr(name); 不起作用并显示错误:

函数“strupr”的隐式声明在 C99 中无效。

所以我回到SO寻找可能的解决方案。有一个说要转到语言方言并将其更改为C11。我这样做了,但仍然无法执行,显示相同的错误消息。我需要做其他事情才能让它运行吗?

谢谢

I am just getting introduced to string in C, and my teacher uses CodeBlocks on windows and I'm using Xcode.
He introduced me to this:

#include <stdio.h>
#include <string.h>
int main()
{
    char name[15];
    printf("Enter your name ");
    scanf("%[^\n]s\n",&name);
    printf("Welcome, %s !",name);
    size_t a=strlen(name);
    printf("Your name is %zu\n",a);
    strupr(name);
    printf("\n")
}

But when I do this same program in Xcode, strupr(name); doesn't work and shows the error:

Implicit declaration of function 'strupr' is invalid in C99.

So I came back to SO to look for possible solutions. There was one where it said to go to language dialect and change it to C11. I did it, but it still would not execute, showing the same error message. Do I need to do something else to make it run?

Thanks

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文