Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework


Working with null-Terminated Strings



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə86/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   82   83   84   85   86   87   88   89   ...   294
DelphiLanguageGuide

Working with null-Terminated Strings
Many programming languages, including C and C++, lack a dedicated string data type. These languages, and
environments that are built with them, rely on null-terminated strings. A null-terminated string is a zero-based array
of characters that ends with NUL (#0); since the array has no length indicator, the first NUL character marks the end
of the string. You can use Delphi constructions and special routines in the 
SysUtils
 unit (see Standard routines
and I/O) to handle null-terminated strings when you need to share data with systems that use them.
For example, the following type declarations could be used to store null-terminated strings.
72


type
  TIdentifier = array[0..15] of Char;
  TFileName = array[0..259] of Char;
  TMemoText = array[0..1023] of WideChar;
With extended syntax enabled (
{$X+}
), you can assign a string constant to a statically allocated zero-based
character array. (Dynamic arrays won't work for this purpose.) If you initialize an array constant with a string that is
shorter than the declared length of the array, the remaining characters are set to 
#0
.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   82   83   84   85   86   87   88   89   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin