c中如何将垃圾值分配给变量 [英] How garbage values are assigned to variables in c

查看:36
本文介绍了c中如何将垃圾值分配给变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C 代码:

int a;
printf("
	 %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屋!

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