Re: Strings, Eu2.1, Linux and C
- Posted by Brian & Alice Clausing <clausing at ERINET.COM> Nov 23, 1998
- 416 views
I can't resist getting a quibble into this discussion. There are no strings as such in the Pascal language standard. There are fixed array of char. The language doesn't specify how a particular implementation stores things so long as the language standards are met. Borland Turbo Pascal has a string type as described in which the length of the string is stored in byte 0 and the characters thereafter. Object Pascal, the language of Borland (Inprise) Delphi, has ShortString like Turbo and String, a class with strings of essentially unlimited length with automatic garbage collection. Object Pascal also has PChar, a pointer to a null-terminated sequence of characters, just like C. This is necessary to get to the Win95 API. (Long) strings and PChar references are interconvertible, and there are utility routines to convert among all the types including, of course, fixed array of char. Other implementations do what seems best to the implementer. For example, one would expect a Unix Pascal compiler to store strings as C does. So the answer to how strings are stored depends on what compiler you're interested in. Regards, Brian Clausing Daniel Berstein wrote: > > >[Strings] > >Does anyone know how languages like Pascal and Basic etc store their > >strings? > > Pascal stores the length of the string in the first byte. > > Regards, > Daniel Berstein > daber at pair.com