Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!udel!princeton!phoenix!pucc!MJSCHMEL From: MJSCHMEL@pucc.Princeton.EDU (Michael J. Schmelzer) Newsgroups: comp.sys.mac.programmer Subject: strings again Message-ID: <4629@pucc.Princeton.EDU> Date: 3 Mar 88 02:10:41 GMT Reply-To: MJSCHMEL@pucc.Princeton.EDU Organization: Princeton University, NJ Lines: 46 Disclaimer: Author bears full responsibility for contents of this article Thank you everybody for the help in converting C to Pascal strings. I had got it right, but was a victim of my own prototyping. To wit: pascal void Debugger() extern 0xA9FF; pascal void DebugStr(aString) Str255 aString; extern 0xABFF; static char *str = "Wowwy zowwy"; main() { char buffer[255]; Debugger(); /* works, no problem */ strcpy(buffer, str); c2pstr(buffer); DebugStr(buffer); /* type mismatch here */ printf("%s\nDone.\n",str); /* it's okay, it's an MPW tool */ } Gave me a "Type mismatch." Why did it do that, I wondered. Then I saw that I had prototyped it that way! (Which shouldn't be faulted, because I got it verbatim from the MPW manual.) Changing the prototype to... pascal void DebugStr(aString) char * aString; extern 0xABFF; ...made it work like a charm. No problem. Is there any way I could have made it work with the original prototype? Simple typecasting - DebugStr ((Str255) buffer); - did not work. (Why not?) Yo Apple! How would I make the program work if it was prototyped as a Str255??? Thanks everyone. ============================================================================== comes around Mike Schmelzer MJSCHMEL@PUCC.Princeton.Edu what goes around ==============================================================================