Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!julius.cs.uiuc.edu!apple!well!oster From: oster@well.sf.ca.us (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: Str255 in C Message-ID: <22647@well.sf.ca.us> Date: 15 Jan 91 09:21:07 GMT References: <1991Jan13.210327.9613@ux1.cso.uiuc.edu> <48035@apple.Apple.COM> Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 18 For safety, you shouldn't use strcpy on arbitrary pascal strings, since ones read from resources won't have length bytes. I use: /* StrMove - copy a pascal string from src to dest analagous to BlockMove() */ void StrMove(src, dest)Str255 src, dest;{ BlockMove(src, dest, Length(src) + 1); } where Length(s) is defines as: #define Length(s) ((short) (unsigned char) (s)[0]) so that I can be sure the length will be interpreted as a SIGNED integer in the range 0..255. Without the casts, 0 - s[0] can return large positive numbers, due to the nature of unsigned arithmetic in C. -- -- David Phillip Oster - At least the government doesn't make death worse. -- oster@well.sf.ca.us = {backbone}!well!oster