如何将垃圾值分配给c中的变量 [英] How garbage values are assigned to variables in c
本文介绍了如何将垃圾值分配给c中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
C代码:
int a;
printf("\n\t %d",a); // It'll print some garbage value;
那么如何将这些垃圾值分配给C语言幕后的未初始化变量?
So how does these garbage values are assigned to uninitialized variables behind the curtains in C?
这是否意味着C首先将内存分配给变量'a',然后该内存位置处的值变成了'a'的值?还是其他?
Does it mean C first allocates memory to variable 'a' and then what ever there is at that memory location becomes value of 'a'? or something else?
推荐答案
这是否意味着C首先将内存分配给变量'a',然后该内存位置处的值变成了'a'的值?
Does it mean C first allocates memory to variable 'a' and then what ever there is at that memory location becomes value of 'a'?
完全正确!
基本上,C不会做您不告诉您的任何事情.这既是优点,也是缺点.
Basically, C doesn't do anything you don't tell it to. That's both its strength and its weakness.
这篇关于如何将垃圾值分配给c中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文