C语言未初始化变量输出的是随即数

 1 #include <stdio.h>
 2 int main(void)
 3 {
 4     int i,o,p,h;
 5     printf("%d\n",i);
 6     printf("%d\n",o);
 7     printf("%d\n",p);
 8     printf("%d\n",h);
 9     getch();
10     return 0;
11 }

对于未初始化的变量,输出的是一个随即数,如下图:

1 编译器: Default compiler
2 执行  gcc.exe...
3 gcc.exe "D:\Documents\Desktop\main.c" -o "D:\Documents\Desktop\main.exe"   -g3  -I"d:\c\DEV-CPP\include"   -L"d:\c\DEV-CPP\Lib" -g3 
4 执行结束
5 成功编译

 

具体的默认值与你的编译器有关。

posted @ 2013-05-31 12:27  Anleb  阅读(1726)  评论(5编辑  收藏  举报