什么是printf的打印一个未初始化变量? [英] What does printf print for an unitialized variable?

查看:119
本文介绍了什么是printf的打印一个未初始化变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该是什么的code打印? 0或任何垃圾的价值还是会依赖于编译器?

 的#include<&stdio.h中GT;
int类型的;
诠释的main()
{
   的printf(%d个\\ N,一);
   返回0;
}


解决方案

答案为0全局变量初始化为零。

What should the code print? 0 or any garbage value or will it depend on the compiler?

#include <stdio.h>
int a;
int main() 
{ 
   printf("%d\n",a);
   return 0;
}

解决方案

the answer is 0. Global variables are initialized to zero.

这篇关于什么是printf的打印一个未初始化变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆