TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Steven Pasztor
from: david nugent
date: 1993-10-02 23:37:18
subject: Pascal strings

> Is there any way to get C to work with Pascal style strings?

You probably mean 'Turbo Pascal' style strings. :-)  And yes, there is a
difference.  TP is quite a different language from ANSI/ISO Pascal.

But yes - easily. Just create the functions to do so.  str*() functions are
just library functions - the only real "strings" support in C is
that you can declare a NUL terminated 'C' string automatically with:

char mystring[] = "xyz";
  and
char * mystring = "xyz";

I've had to interface with TP code on many occasions and there's not much
to it.  Just handle the pascal strings as arrays of unsigned chars with a
byte up front.  Once you get sick of the 255 character limit, you'll
probably not worry about using them unless interfacing to structures
designed for TP.  Or, you'll upgrade to C++ and write a string class which
handles all the fiddling required for more useful schemes transparently.


david

---

* Origin: Unique Computing Pty Ltd (3:632/348)
SEEN-BY: 50/99 54/54 99 620/243 622/405 623/630 632/103 301 348 365 386 998
SEEN-BY: 633/371 634/383 384 635/502 503 544 555 570 636/100 670/206 711/401
SEEN-BY: 711/409 430 807 808 809 932 934 712/623 627 713/888 714/906 800/1
@PATH: 632/348 635/503 50/99 54/54 99 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.