1. Strings, Eu2.1, Linux and C
- Posted by Mathew Hounsell <mat.hounsell at MAILEXCITE.COM> Nov 22, 1998
- 516 views
- Last edited Nov 23, 1998
[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/
2. Re: Strings, Eu2.1, Linux and C
- Posted by Daniel Berstein <daber at PAIR.COM> Nov 23, 1998
- 462 views
>[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
3. Re: Strings, Eu2.1, Linux and C
- Posted by Brian & Alice Clausing <clausing at ERINET.COM> Nov 23, 1998
- 488 views
- Last edited Nov 24, 1998
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