1. Strings, Eu2.1, Linux and C

[Strings]
Does anyone know how languages like Pascal and Basic etc store their
strings?

[Eu2.1]
Can't wait.

[Linux]
I was going to install it when I got another HDD and now I have more
insentive.

[C]
Pete, Dave and Rob aren't the only ones who code in C. I fear I'm going to
have to read a C library to do what I need. C++ is better to read. B is
worse, no types.
--------------------
Sincerely,
Mathew Hounsell

Mat.Hounsell at MailExcite.Com




_______________________________________________________
Get your free, private e-mail at http://mail.excite.com/

new topic     » topic index » view message » categorize

2. Re: Strings, Eu2.1, Linux and C

>[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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Strings, Eu2.1, Linux and C

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu