Yinsel 发表于 2021-10-13 18:31:24

vscode--scanf输入中文问题

如题,printf正常输出中文字符,为什么scanf输入中文后不能正常输出中文?

#include <stdio.h>

int main(){
    int a;
    char name;
    a=scanf("%s",name);
    printf("%d",a);
    printf("\n%s",name);
    return 0;
}

Yinsel 发表于 2021-10-13 18:32:12

vscode F5调试输入中文会输出错误,求解

hrpzcf 发表于 2021-10-13 18:46:42

我这vscode可以正常输出中文啊,你那输出的是什么?
PS F:\code> GCC -fexec-charset=GBK test.c -o test ; if ($?) { .\test }
你好
1
你好      
PS F:\code>

泌阳 发表于 2021-10-13 21:28:58

你程序有问题,你那数组怎么控制啊。
页: [1]
查看完整版本: vscode--scanf输入中文问题