如何将所有位的整数数组设置为零? [英] How can I set a integer array all bits to zero?

查看:95
本文介绍了如何将所有位的整数数组设置为零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



#include< string.h>


int a [100];


memset (a,0,sizeof(a));


这是否保证所有位为零?


-

|

___

(-_-)

< | |> ---------------------------------- ShepJeng.twbbs.org -------- -----

/ plum.cs.nccu.edu.tw


#include <string.h>

int a[ 100 ];

memset( a, 0, sizeof(a) );

Does that guarantee all bits zero?

--
|
___
(-_-)
<| |>---------------------------------- ShepJeng.twbbs.org -------------
/ plum.cs.nccu.edu.tw

推荐答案

我希望写道:
#include< string.h>

int a [100];

memset(a,0,sizeof(a));

是否保证所有位为零?
#include <string.h>

int a[ 100 ];

memset( a, 0, sizeof(a) );

Does that guarantee all bits zero?




取决于,C90否,C99是。


两者:int a [100] = {0};


Jirka



Depends, C90 no, C99 yes.

Both: int a[100] = {0};

Jirka


Jirka Klaue写道:
Jirka Klaue wrote:
我希望写道:
I wish wrote:
#include< string.h>

int a [100];

memset(a,0,sizeof(a));

这是否保证所有位为零?

取决于,C90否,C99是。
#include <string.h>

int a[ 100 ];

memset( a, 0, sizeof(a) );

Does that guarantee all bits zero?

Depends, C90 no, C99 yes.



你引起了我的好奇心。如果使用C99,memset保证

所有位为零?

两者:int a [100] = {0};


You piqued my curiosity. What''s up with C99 that the memset guarantees
all bits zero ?
Both: int a[100] = {0};



-

Bertrand Mollinier Toublet

"首席开发人员。铁开发者。铜开发商。 - Sean Egan


--
Bertrand Mollinier Toublet
"Lead developer. Iron developer. Copper developer." -- Sean Egan


Jirka Klaue写道:
Jirka Klaue wrote:

我希望写道:

I wish wrote:
#include< string.h>

int a [100];

memset(a,0,sizeof(a));
这是否保证所有位为零?
#include <string.h>

int a[ 100 ];

memset( a, 0, sizeof(a) );

Does that guarantee all bits zero?



取决于,C90否,C99是。



Depends, C90 no, C99 yes.




没有 ;取决于"关于它:在所有版本的

标准中,a被此代码设置为所有位零。


*依赖于什么*标准版是

所有位零是否与零值相同。在C89 / 90中,所有位为零的

`int''的值为零。在C99中,

其中int允许包含不是其值的一部分(填充位)的位,有可能是

零值int可能包含非零位,并且它可能是一个所有位为零的int可能

是一个陷阱表示。


-
Er ********* @ sun.com


这篇关于如何将所有位的整数数组设置为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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