Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!hellgate.utah.edu!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: Quick ThinkC String question... Keywords: THINK C STRING Message-ID: <4847@helios.ee.lbl.gov> X-Local-Date: 14 Feb 90 02:25:59 PST Date: 14 Feb 90 10:25:59 GMT References: <77108@tut.cis.ohio-state.edu> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Distribution: usa Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 33 In article <77108@tut.cis.ohio-state.edu> writes: #Hi, # #I'm having a problem getting ThinkC to accept the following: # #procedureX() #{ # Str255 myString; # # myString = "\pExample string"; #} # #which a reference book said was correct. At certain times I've used strcpy(myString, "\pExample string"); MPW C certainly allows this, as a length byte and null are generated in MPW C's string constants. I'm not sure if THINK C's have nulls. And obviously this won't work in general for all pascal strings. How about: pstrcpy(StringPtr dest, StringPtr src) { register short len = src[0]; dest[0] = len; /* save length. */ while(len--) *++dest = *++src; } This should be general enough... (please no flames, I composed this here.) ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------