473,883 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Zero out Array

Is there a quick way to fill an array with zeros or make all elements
empty/nothing?
Nov 21 '05
13 8753
I have a multi-dimensional array, would I need to:

array.Clear(MyA rray,0,MyArray. Length)
array.Clear(MyA rray,1,MyArray. Length)
array.Clear(MyA rray,2,MyArray. Length)
array.Clear(MyA rray,3,MyArray. Length)

?

"Rick Mogstad" <Ri**********@G Mail.NOSPAM.com > wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
array.Clear(MyA rray,0,MyArray. Length)

"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:iO******** ************@co mcast.com...
Is there a quick way to fill an array with zeros or make all elements
empty/nothing?


Nov 21 '05 #11
OK, Length is the total size of the array including all dimensions. So
starting at 0 and going to Length would clear all dimensions.

Do I have that right?

Thank you again.
"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:d7******** ************@co mcast.com...
I have a multi-dimensional array, would I need to:

array.Clear(MyA rray,0,MyArray. Length)
array.Clear(MyA rray,1,MyArray. Length)
array.Clear(MyA rray,2,MyArray. Length)
array.Clear(MyA rray,3,MyArray. Length)

?

"Rick Mogstad" <Ri**********@G Mail.NOSPAM.com > wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
array.Clear(MyA rray,0,MyArray. Length)

"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:iO******** ************@co mcast.com...
Is there a quick way to fill an array with zeros or make all elements
empty/nothing?



Nov 21 '05 #12
Hmm. Probably, you would have to try it out. I dont use multi-dimensional
arrays much, so I havent tried it.
"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:Mu******** ************@co mcast.com...
OK, Length is the total size of the array including all dimensions. So
starting at 0 and going to Length would clear all dimensions.

Do I have that right?

Thank you again.
"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:d7******** ************@co mcast.com...
I have a multi-dimensional array, would I need to:

array.Clear(MyA rray,0,MyArray. Length)
array.Clear(MyA rray,1,MyArray. Length)
array.Clear(MyA rray,2,MyArray. Length)
array.Clear(MyA rray,3,MyArray. Length)

?

"Rick Mogstad" <Ri**********@G Mail.NOSPAM.com > wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
array.Clear(MyA rray,0,MyArray. Length)

"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:iO******** ************@co mcast.com...
Is there a quick way to fill an array with zeros or make all elements
empty/nothing?



Nov 21 '05 #13
It seems to be working. Thank you.
"Rick Mogstad" <Ri**********@G Mail.NOSPAM.com > wrote in message
news:e1******** ******@TK2MSFTN GP12.phx.gbl...
Hmm. Probably, you would have to try it out. I dont use
multi-dimensional arrays much, so I havent tried it.
"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:Mu******** ************@co mcast.com...
OK, Length is the total size of the array including all dimensions. So
starting at 0 and going to Length would clear all dimensions.

Do I have that right?

Thank you again.
"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:d7******** ************@co mcast.com...
I have a multi-dimensional array, would I need to:

array.Clear(MyA rray,0,MyArray. Length)
array.Clear(MyA rray,1,MyArray. Length)
array.Clear(MyA rray,2,MyArray. Length)
array.Clear(MyA rray,3,MyArray. Length)

?

"Rick Mogstad" <Ri**********@G Mail.NOSPAM.com > wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
array.Clear(MyA rray,0,MyArray. Length)

"DazedAndConfus ed" <Ac********@yah oo.com> wrote in message
news:iO******** ************@co mcast.com...
> Is there a quick way to fill an array with zeros or make all elements
> empty/nothing?
>



Nov 21 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4749
by: Steven T. Hatton | last post by:
I mistakenly set this to the comp.std.c++ a few days back. I don't believe it passed the moderator's veto - and I did not expect or desire anything different. But the question remains: ISO/IEC 14882:2003(E) §8.5 says:   To zero-initialize an object of type T means: 5   -- if T is a scalar type (3.9), the object is set to the value of 0 (zero) converted to T;
13
27221
by: simondex | last post by:
Hi, Everyone! Does anyone know how to initialize an int array with a non-zero number? Thank You Very Much. Truly Yours, Simon Dexter
14
2502
by: dam_fool_2003 | last post by:
Hai, When I declare a zero-based array I get a compile time error stating that zero based array is not possible. But if I declare the same in the function argument I don't get any error. Is related with the function in C in which the argument's references are passed in the stack during the runtime. I am confused.
25
2711
by: prashna | last post by:
Hi all, I have seen a piece of code(while doing code review) which declared an array of size 0.One of my friend told although it is not standard C,some compilers will support this..I am very curious to know the use of it.. The code was compiled using Diab C compiler. Also the array was declared in structure like this typedef struct someStruct
26
26258
by: 69dbb24b2db3daad932c457cccfd6 | last post by:
Hello, I have to initialize all elements of a very big float point array to zero. It seems memset(a, 0, len) is faster than a simple loop. I just want to know whether it is safe to do so, since I know it's danger to initialize NULL pointers this way. But how about floats? Zhang Le
15
2144
by: Tomás | last post by:
Is the following fully legal and fully portable for all the unsigned types? The aim of the function is to take an array by reference and set each element's value to zero. #include <... template<class UnsignedNumericType, std::size_t const i> void SetAllElementsToZero( UnsignedNumericType (&array) ) { memset( array, 0, i * sizeof(UnsignedNumericType) );
14
52492
by: rocketman768 | last post by:
Man, that title should be in a poem, but anyways...So, I have this program, and it has an array of 40 million elements. The problem is that I have a for loop that continually is doing stuff to this array, and for each iteration, I have to zero out the array. This is how I am currently doing it: // Zero out the lnscores for( count=0; count < chunksize; count++ ) lnscores = 0; Is there no quicker way to do this? I know there must be...
22
2311
by: spam.noam | last post by:
Hello, I discovered that I needed a small change to the Python grammar. I would like to hear what you think about it. In two lines: Currently, the expression "x" is a syntax error. I suggest that it will be evaluated like "x", just as "x" is evaluated like "x" right now.
19
7091
by: nileshsimaria | last post by:
Hi, I have seen some code were we have array with zero elements (mostly within structure) like, typedef struct foo { int data }foo;
37
2355
by: Ajai Jose | last post by:
Hi , I work on an ARM processor based embedded system. Code is mainly in C language. The project has a huge source base. We are supposed to optimise it. Most datastructures are declared as static and which directly go into the Zero Initialised region. We need to cut the size of this ZI region by at least 30%. The one way i see of doing this is by removing these static arrays and passing a pointer to the data structure whenever required....
0
9932
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9777
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10728
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10833
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7959
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3227
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.