Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!src.honeywell.com!msi.umn.edu!cs.umn.edu!quest!orbit!kksys!jhereg!andrew From: andrew@jhereg.osa.com (Andrew C. Esh) Newsgroups: comp.sys.mac.programmer Subject: Re: P-strings in MPW C++ Keywords: C++ Message-ID: <1991Feb21.200733.10599@jhereg.osa.com> Date: 21 Feb 91 20:07:33 GMT References: <12035@pt.cs.cmu.edu> Organization: Open Systems Architects, Inc., Mpls, MN Lines: 35 In article <12035@pt.cs.cmu.edu> mkb@rover.ri.cmu.edu (Mike Blackwell) writes: > >In MPW C++, the following code snippet compiles fine: > #include > char foo[10]; > strcpy(foo, "bar"); >but if I replace "bar" with "\pbar", I get a bad argument error, stating >that a const char * was expected, but it got an unsigned char [5] instead. >Why is this? I know I can coerce it with a (char *)"\pbar", but that's ugly. > >What I really want is something like: Str255 foo; strcpy(foo, "\pbar"); but >again, CFront doesn't like a Str255 in place of a char *. Why not? Is there >a better way to achieve the same effect without type coercing both arguments? Yes, and if you had read the manual, you would have saved time. Page 170 of the MPW 3.0 C Reference manual has the section "Passing String Parameters", which describes the routines: char *p2cstr(StringPtr aStr); StringPtr c2pstr(char *aStr); which will do the job. They are declared in Strings.h and reside in the library CInterface.o. > >Thanks for any insight... Mike Blackwell > mkb@rover.ri.cmu.edu -- Andrew C. Esh andrew@osa.com (612)525-0000 Open Systems Architects, Inc. Minneapolis, MN 55416-1528 Does the universe really exist? Try starting from the opposite assumption and see where that gets you.