The C language was designed (during the early 1970's) to use a "null" character
(binary zero represented by escape character "\0")
to mark the end of each string.
This design can lead to "off-by-one" errors when an extra space is not allocated to hold that extra unseen character.
A 4 character string requires a static allocation of 5 bytes.
If a 4 character string is copied to a variable created as having 4 bytes,
an invisible null character flows into the adjacent variable in memory.
That adjacent variable will now appear to be blank
because a binary zero value within a string truncates that string,
Such a "null termination" errors are so common that discussion boards are filled with the
acronym DFTTZ for "Don't Forget The Terminating Zero".
C's unbounded overlay of memory allows programs to "smash the stack"
of memory variables.
These errors are notoriously difficult to find because most C compiler do not catch such errors
and because the adjacent variable is not always the next variable defined in the code.
So such errors lie dormant in deployed code until a particular set of inputs causes a failure.
This is a common exploit used by hackers.
This is why Microsoft Visual Studio 2005 deprecated common
C string functions such as strcpy(), strcat(), gets(), streadd(), strecpy(), and strtrns().
Those who must work with traditional C functions statically allocate a large string size
(such as 4000) to make enough room.
This approach bloats the program's memory footprint.
The workaround is to test the length of the input using strlen() and either put out an error message or
dynamically allocate the string size needed.
This, unfortunately, also has the potential of creating memory leaks over time if memory is not
deallocated.
BTW, all this is actually an improvement to how strings are handled in the Pascal language,
which uses the first byte to store the length of the string.
Since computers used 4 bits per byte, strings in Pascal are limited to 256 bytes.
LPCSTR (Long Pointer to Const String) is a pointer to a null (zero)
terminated sequence of ANSI bytes.
The System.String class in the Microsoft C# language is defined as a sealed class,
which prevents it from being inherited, for security reasons.