软件 devc++ 6.5
######我想知道c=i;写在scanf前一行时 为什么会报错。
#include<stdio.h>
int main() {
int i;
char c;
c = i;
scanf ("%d", &i);
printf("c=%d\n", c);
printf("c='%c'In", c);
return 0;
}
报错
[Warning] 'i' is used uninitialized in this function [-Wuninitialized]
int i; 只是定义了,还没有初始化,值是未知的,你直接赋值给一个char, char的范围~128 到 127, 很可能就超了,c语言不允许
这还用说么,i还没输入呢,你写c=i毫无意义啊