gpt4 book ai didi

c - 垃圾值如何分配给c中的变量

转载 作者:IT王子 更新时间:2023-10-28 23:36:57 26 4
gpt4 key购买 nike

C 代码:

int a;
printf("\n\t %d",a); // It'll print some garbage value;

那么这些垃圾值是如何在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'?

没错!

基本上,C 不会做任何你没有告诉它的任何事情。这既是它的强项,也是它的弱点。

关于c - 垃圾值如何分配给c中的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15326611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com