home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!jvnc.net!yale.edu!yale!gumby!kzoo!k044477
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Subject: Re: Comparing strings 'n stuff...
- Message-ID: <1992Aug28.191116.6242@hobbes.kzoo.edu>
- Organization: Kalamazoo College
- References: <1992Aug28.134804.9876@sun1x.actc.res.utc.com> <D88-JWA.92Aug28194218@dront.nada.kth.se>
- Date: Fri, 28 Aug 1992 19:11:16 GMT
- Lines: 41
-
- d88-jwa@dront.nada.kth.se (Jon W{tte) writes:
- >> rer@utrcv1.res.utc.com (Rick E Romkey) writes:
- >
- > I am trying to compare a Str255 with a String which exists
- > in my resource file.
- >
- > Boolean CompareStrings( Str255 inString )
- > {
- >
- >WRONG WRONG WRONG. Should say "unsigned char * inString" and
- >not Str255 inString, since you're passing a reference to an
- >array.
-
- Er, much as I hate to correct the master, there's nothing wrong with an
- argument of type Str255. It resolves to:
-
- Boolean CompareStrings(unsigned char inString[256])
-
- ...and there's nothing wrong with that. They amount to the same thing.
-
-
- While I'm wasting bandwidth, allow me to point out that converting P to
- C strings and using strcmp is not only accent-unfriendly, but inefficient.
- If you want 'e', 'E', and '<e-acute>' to be considered different, you
- may as well write:
-
- Boolean pstringsAreEqual(Str255 s1, Str255 s2)
- {
- short len = s1[0];
- short i;
- if (s2[0] != len) return FALSE;
- for (i = 1; i <= len; ++i) {
- if (s1[i] != s2[i]) return FALSE;
- }
- return TRUE;
- }
- --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- "It's bad enough to send a rude message to another via such an anonymous
- channel [as email]. To flame someone on an open forum is, to me, the
- height of insensitivity." - P.J. Plauger
-