C 扫描字符串时,mingw出错

C 扫描字符串时,mingw出错,c,mingw,C,Mingw,我刚刚安装了mingw。我正在测试它。我只是写了一个简单的程序。但这是一个错误。有什么问题吗 int main() { char name[10]; printf("Enter your name\t"); scanf("%s", &name); printf("Hello %s",name); return 0; } 错误是 - format '%s' expects argument

我刚刚安装了mingw。我正在测试它。我只是写了一个简单的程序。但这是一个错误。有什么问题吗

 int main()
    {
        char name[10];
        printf("Enter your name\t");
        scanf("%s", &name);
        printf("Hello %s",name);
        return 0;
    }
错误是

- format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[10]' [-
     Wformat]

- Line breakpoint: sorts.c [line: 16]
更改:

scanf("%s", &name);

&name
是指向
char
的数组
10
的指针,
name
是转换为函数调用表达式中指向
char
的数组
10
s
转换说明符需要指向
char
参数的指针。

更改:

scanf("%s", &name);


&name
是指向
char
的数组
10
的指针,
name
是转换为函数调用表达式中指向
char
的数组
10
s
转换说明符需要指向
char
参数的指针。

项目中仍然存在错误。无法打开输出文件,test1.exe权限被拒绝。在我修好它之后。我在发布问题之前按照你说的做了,但是权限问题发生了。@shryaskale打开一个新问题,解释如何编译程序以及出现了什么错误。project中仍然存在错误。无法打开输出文件,test1.exe权限被拒绝。在我修好它之后。我按照你在发帖前说的做了,但是权限问题正在发生。@shryaskale打开一个新的问题,解释你是如何编译程序的,以及你会遇到什么错误。