代码在vc6.0里面可以运行,在vs2010里面,就会出现The variable‘c1’is being used without being initialized报错

#include <stdio.h>
#include <stdlib.h>
void main()
{
char c1,c2;
printf("请随机输入一个大写字母:");
scanf("%c",c1);
c2=c1+32;
printf("%c\n",c2);
system("pause");
}

scanf("%c",c1);改成 scanf("%c",&c1);

变量没有初始化值的意思。

改成这样应该就不会报错了。。。


#include <stdio.h>
#include <stdlib.h>


void main() {
    char c1 = '\0', c2 = '\0';

    printf("请随机输入一个大写字母:");
    scanf("%c", &c1);

    c2 = c1 + 32;
    printf("%c\n", c2);

    system("pause");
}
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632