Freepascal follows the turbo-pascal string type convention. Walter
Savitch's book calls them "turbo-strings." They have some different
properties that make them both useful and difficult. I hope the real
freepascal experts will correct my errors.
First, the string data type is created at compile time. Unlike C
pointers created dynamically.
Second, a Pascal string is an indexed array. So a character can be
addressed like S[3]. A length byte is at S[0].
Third, string variables are passed to procedures as pointers.
To create C strings (null terminated pointers to a sequence of
characters) one might do the following;
Function Create_Cstring(PascalString : String) : Cstring;
Var NewString : String;
Convert_To_Cstring : Cstring;
Begin
NewString := PascalString + Chr(0) ;
Convert_To_Cstring := @[EMAIL PROTECTED]
;
Create_Cstring := StrNew(Convert_To_Cstring) ;
End;
These capabilities seem assets and not liabilities.
Turbo-Strings are different with some good reasons. Not necessarily a
fault.