How garbage values are assigned to variables in c

后端 未结 4 366
后悔当初
后悔当初 2020-11-29 11:59

C code :

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

So how does these garbage values are assigne

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 13:03

    Does it mean C first allocates memory to variable 'a' and then what ever there is at that memory location becomes value of 'a'?

    Exactly!

    Basically, C doesn't do anything you don't tell it to. That's both its strength and its weakness.

提交回复
热议问题