未初始化的价值观? [英] Uninitialized values?
问题描述
您好,
初始化变量的默认值是什么?
例如
int d; // debug给我-858993460
char c; // debug给我-52
我使用VS.net 2005
谢谢。
Hello,
What are the default value for initialized variable?
e.g.
int d; // debug give me -858993460
char c; // debug give me -52
I am using VS.net 2005
Thanks.
推荐答案
howa写道:
howa wrote:
你好,
初始化变量的默认值是什么? br />
例如
int d; // debug给我-858993460
char c; // debug给我-52
我使用的是VS.net 2005
谢谢。
Hello,
What are the default value for initialized variable?
e.g.
int d; // debug give me -858993460
char c; // debug give me -52
I am using VS.net 2005
Thanks.
没有默认值,只是偶然位在
内存位置。
>
如果你想要一个非随机值,只需要它:
int d = 0;
char c =''a '';
Bo Persson
There is no default value, just the random bits that happen to be in
that memory location.
If you want a non-random value, just ask for it:
int d = 0;
char c = ''a'';
Bo Persson
howa写道:
howa wrote:
你好,
初始化变量的默认值是什么?
例如
int d; // debug给我-858993460
char c; // debug给我-52
我使用VS.net 2005
Hello,
What are the default value for initialized variable?
e.g.
int d; // debug give me -858993460
char c; // debug give me -52
I am using VS.net 2005
它是'未指定或实现定义。
但是,在VS的情况下,它都是cc'。
It''s either unspecified or implementation defined.
However, in the case of VS, it''s all cc''s.
howa写道:
howa wrote:
您好,
初始化变量的默认值是什么?
>
例如
int d; // debug给我-858993460
char c; // debug给我-52
我正在使用VS.net 2005
Hello,
What are the default value for initialized variable?
e.g.
int d; // debug give me -858993460
char c; // debug give me -52
I am using VS.net 2005
现在我想到了,值未定义,访问
未定义变量是未定义的行为。
Now that I think of it, the value is undefined, and accessing an
undefined variable is undefined behavior.
这篇关于未初始化的价值观?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!