logoalt Hacker News

jxbdbdtoday at 6:47 AM2 repliesview on HN

Why would a pascal string be any shorter than a C string?

A C string is one pointer reaching all of memory, a Pascal string is two pointers reaching all of memory


Replies

bc_programmingtoday at 7:24 AM

A pascal string is a single byte with the length, followed by the data.

Some implementations use more bytes for the length data, such as Delphi which changed over to a 4 byte prefix length, though those aren't technically Pascal strings anymore. I can't find anything about a Pascal string being two pointers?

show 2 replies
Conscattoday at 7:22 AM

A Pascal string has a leading length byte. Because that is one byte, the text can't exceed 255 characters.

show 1 reply