By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,375 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

What are SZ array?

P: n/a
I was reading an article regarding .Net arrays and on that article,
the author mentioned something about SZ arrays.

As far as I can tell, SZ arrays are one dimension arrays that are zero
based, am I correct on this? Also, can someone tell me what does SZ
stands for?

Thank you.
Jun 30 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Mon, 30 Jun 2008 09:31:51 -0700, <qg**********@mailinator.comwrote:
I was reading an article regarding .Net arrays and on that article,
the author mentioned something about SZ arrays.

As far as I can tell, SZ arrays are one dimension arrays that are zero
based, am I correct on this? Also, can someone tell me what does “SZ”
stands for?
Without a quote that provides enough context, I don't see how anyone could
answer the question.

Pete
Jun 30 '08 #2

P: n/a
On Jun 30, 11:46*am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Mon, 30 Jun 2008 09:31:51 -0700, <qglyirnyf...@mailinator.comwrote:
I was reading an article regarding .Net arrays and on that article,
the author mentioned something about SZ arrays.
As far as I can tell, SZ arrays are one dimension arrays that are zero
based, am I correct on this? Also, can someone tell me what does SZ
stands for?

Without a quote that provides enough context, I don't see how anyone could *
answer the question.

Pete
Quote:

Hi Pete,

---------------------------
Article quote:

When possible, you should try to stick with single-dimensioned, zero-
based arrays (sometimes referred to as SZ arrays or vectors).
---------------------------

Just curious if the term "SZ arrays" always refer to "single-
dimensioned, zero-based" or is the term used for other types. I am
also curious to know what "SZ" stands for, probably a C/C++ naming
conversion of some sort.

Thanks
Jun 30 '08 #3

P: n/a
This is probably referring to the way that strings were represented in C and
C++, before Unicode and other languages such as VB came along. Strings, in
those days and those languages, were maintained in memory as one-dimensional
arrays of bytes, with each byte containing a character (or 'char'). The
characters in the string were followed by a single byte with a value of
binary zero. This was also called a 'null byte', and one might say of such a
string that it was 'null-terminated'.

The byte array (or char array) was allocated at fixed length (the 'character
buffer') and the byte or character count included space for the terminating
null character. So a string variable could contain any number of characters,
including zero characters, up to the length of the buffer minus one, because
the null-terminating character had to be there to satisfy the C/C++ runtime
code. The C and C++ runtime understood this convention, and the programmer
had to as well, so as to always allocate string variables with enough space
to contain the terminating null character.

This convention has become one of the most popular attack vectors for
hacking - the "buffer overflow" that you always are hearing about - because
it's easy to store into one of those byte arrays a string that's longer than
the size of the array, and programmers are typically negligent about
checking that an input string is not too large to store into the space
allocated.

In Microsoft's ghastly old Hungarian notation - invented by Charles Simonyi
and badly misused by Microsoft programmers for a long time afterwards - it
was common to prefix the name of a string variable with the characters 'sz'
(meaning 'zero-terminated string').

This is still supported in Microsoft's C and C++ languages.

Tom Dacon
Dacon Software Consulting

Jon Skeet will be along in a minute to correct my account of this, so don't
consider this question answered until he has weighed in on the issue :-)
<qg**********@mailinator.comwrote in message
news:00**********************************@s50g2000 hsb.googlegroups.com...
I was reading an article regarding .Net arrays and on that article,
the author mentioned something about SZ arrays.

As far as I can tell, SZ arrays are one dimension arrays that are zero
based, am I correct on this? Also, can someone tell me what does SZ
stands for?

Thank you.
Jun 30 '08 #4

P: n/a
I see from your follow-up post that the original author uses a different
meaning altogether for the term 'SZ array', so you may disregard my
explanation of a much different meaning of the term.

Tom Dacon
Dacon Software Consulting
"Tom Dacon" <td****@community.nospamwrote in message
news:e%****************@TK2MSFTNGP06.phx.gbl...
This is probably referring to the way that strings were represented in C
and C++, before Unicode and other languages such as VB came along.
Strings, in those days and those languages, were maintained in memory as
one-dimensional arrays of bytes, with each byte containing a character (or
'char'). The characters in the string were followed by a single byte with
a value of binary zero. This was also called a 'null byte', and one might
say of such a string that it was 'null-terminated'.

The byte array (or char array) was allocated at fixed length (the
'character buffer') and the byte or character count included space for the
terminating null character. So a string variable could contain any number
of characters, including zero characters, up to the length of the buffer
minus one, because the null-terminating character had to be there to
satisfy the C/C++ runtime code. The C and C++ runtime understood this
convention, and the programmer had to as well, so as to always allocate
string variables with enough space to contain the terminating null
character.

This convention has become one of the most popular attack vectors for
hacking - the "buffer overflow" that you always are hearing about -
because it's easy to store into one of those byte arrays a string that's
longer than the size of the array, and programmers are typically negligent
about checking that an input string is not too large to store into the
space allocated.

In Microsoft's ghastly old Hungarian notation - invented by Charles
Simonyi and badly misused by Microsoft programmers for a long time
afterwards - it was common to prefix the name of a string variable with
the characters 'sz' (meaning 'zero-terminated string').

This is still supported in Microsoft's C and C++ languages.

Tom Dacon
Dacon Software Consulting

Jon Skeet will be along in a minute to correct my account of this, so
don't consider this question answered until he has weighed in on the issue
:-)
<qg**********@mailinator.comwrote in message
news:00**********************************@s50g2000 hsb.googlegroups.com...
I was reading an article regarding .Net arrays and on that article,
the author mentioned something about SZ arrays.

As far as I can tell, SZ arrays are one dimension arrays that are zero
based, am I correct on this? Also, can someone tell me what does "SZ"
stands for?

Thank you.

Jun 30 '08 #5

P: n/a
I see from your follow-up post that the original author uses a different
meaning altogether for the term 'SZ array', so you may disregard my
explanation of a much different meaning of the term.
Actually, thats a pretty good explanation.

So my guess is that the terminology has nothing to do with arrays as
we know them today.

It looks like the term simply stuck since C/C++ string are always
single-dimensioned, zero- based arrays of <chars>, then I can see how
the term got associated to todays single-dimensioned, zero- based
array of <T>.

Thanks.
Jun 30 '08 #6

P: n/a
This naming convention and more regarding arrays is discussed quite
thoroughly in this month's VisualStudio Magazine.

<qg**********@mailinator.comwrote in message
news:00**********************************@s50g2000 hsb.googlegroups.com...
I was reading an article regarding .Net arrays and on that article,
the author mentioned something about SZ arrays.

As far as I can tell, SZ arrays are one dimension arrays that are zero
based, am I correct on this? Also, can someone tell me what does SZ
stands for?

Thank you.

Jun 30 '08 #7

P: n/a
On Mon, 30 Jun 2008 09:58:10 -0700, <qg**********@mailinator.comwrote:
[...]
---------------------------
Article quote:

When possible, you should try to stick with single-dimensioned, zero-
based arrays (sometimes referred to as SZ arrays or vectors).
---------------------------

Just curious if the term "SZ arrays" always refer to "single-
dimensioned, zero-based" or is the term used for other types. I am
also curious to know what "SZ" stands for, probably a C/C++ naming
conversion of some sort.
I've never heard the term before, but based on the quote I'd guess that
the "S" stands for "single-dimension" (or "single-dimensioned") and the
"Z" stands for "zero-based".

It's certainly not part of the standard jargon, and it seems superfluous
to me since in C# all arrays are zero-based.

I'll ignore Tom's flamebait about Hungarian being "ghastly".

Pete
Jul 1 '08 #8

P: n/a
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Mon, 30 Jun 2008 09:58:10 -0700, <qg**********@mailinator.comwrote:
I'll ignore Tom's flamebait about Hungarian being "ghastly".
Not looking for trouble - just my opinion, but I agree that it might have
been better to have left out the adjective so as not to offend those who are
deeply invested in that particular style. However I do believe that there's
fairly broad agreement that Simonyi's original, good, and very useful
technique of semantic (not variable type) prefixes was badly distorted by
various programming groups at Microsoft.

If you have more to say on the topic - which I am not particularly
interested in pursuing - you might consider cracking a new thread instead of
continuing it here.

Tom
Jul 1 '08 #9

P: n/a
qg**********@mailinator.com wrote:
>I see from your follow-up post that the original author uses a
different meaning altogether for the term 'SZ array', so you may
disregard my explanation of a much different meaning of the term.

Actually, thats a pretty good explanation.

So my guess is that the terminology has nothing to do with arrays as
we know them today.

It looks like the term simply stuck since C/C++ string are always
single-dimensioned, zero- based arrays of <chars>, then I can see how
the term got associated to todays single-dimensioned, zero- based
array of <T>.
Not "zero-based". "zero-terminated" is the key point. And yes, it's
equally applicable to arrays of wchar_t as char, and can be extended to any
<Twhere the zero value cannot appear inside the data.
>
Thanks.

Jul 2 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.