Re: What are SZ array?



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" <tdacon@xxxxxxxxxxxxxxxx> wrote in message
news:e%23a2SQt2IHA.5512@xxxxxxxxxxxxxxxxxxxxxxx
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
:-)


<qglyirnyfgfo@xxxxxxxxxxxxxx> wrote in message
news:00fb2d18-0f8a-4d5b-866c-c6c4689f5fb4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.



.



Relevant Pages

  • Re: numpy 00 character bug?
    ... I've recently encountered a bug in NumPy's string arrays, ... It seems that the string array is using the 00 character to pad strings ... using NumPy arrays to store Python structs, ...
    (comp.lang.python)
  • Re: The linf project (2)
    ... character will be declared exactly as in fortran. ...   integer, string:: b ... Should regularity be imposed or only to be preferred in declarations? ... We also need to be able to declare arrays of strings. ...
    (comp.lang.fortran)
  • Re: Characters in Strings
    ... the search-for string within the search-in string. ... To get a single character, ... You can treat them as if they were arrays of characters. ... GetChr = Right, 1) ...
    (microsoft.public.excel.programming)
  • Re: What are SZ array?
    ... before Unicode and other languages such as VB came along. ... arrays of bytes, with each byte containing a character. ... string that it was 'null-terminated'. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Last Ninja Programming Language
    ... So when 88 unique variables just aren't enough (not including arrays). ... than just two character variable names. ... ``GOSUB MoveEnemy`` is much clearer than ``GOSUB 2770`` and ... labels that "compiled" such a program into compact BASIC V2. ...
    (comp.sys.cbm)