Article View: comp.sys.mac
Article #18926RE: LSC printf() and String resource problem
From: Richard Siegel
Date: Thu, 10 Sep 1987 16:35
Date: Thu, 10 Sep 1987 16:35
36 lines
1563 bytes
1563 bytes
I haven't tried the code yet (I will, though) but what immediately strikes me is that
you don't lock the STR resource before you
call printf(). Since printf() calls an assortment of routines
that are in the class of "routines that may move or purge memory",
it's likely that your string is moving away on you.
Try this bit of code and see what happens:
#include <stdio.h>
#include <MacTypes.h>
#include <strings.h>
#include <pascal.h>
#define StringID 30292
main() /* This code works as written. */
{
char **myText;
myText = (char **)GetString(StringID);
HLock((Handle)(myText));
PtoCstr(*myText);
/* sorry about that indent ^^ */
printf("%s\n", *myText);
ExitToShell();
}
As I said, I'll try the code and if I come across anything else I'll post.
--Rich
****NOTE: The opinions (if any) herein are my own opinions and are
in no way representative of my employer's policies.
Richard M. Siegel
Customer Support Representative
THINK Technologies, Inc.
Technical Details
Message-ID:
<YVFhH9y00W0YyhY0HC@andrew.cmu.edu>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!labrea!jade!ucbvax!ANDREW.CMU.EDU!rs4u+Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!labrea!jade!ucbvax!ANDREW.CMU.EDU!rs4u+ From: rs4u+@ANDREW.CMU.EDU (Richard Siegel) Newsgroups: comp.sys.mac Subject: RE: LSC printf() and String resource problem Message-ID: <YVFhH9y00W0YyhY0HC@andrew.cmu.edu> Date: Thu, 10-Sep-87 12:35:21 EDT Article-I.D.: andrew.YVFhH9y00W0YyhY0HC Posted: Thu Sep 10 12:35:21 1987 Date-Received: Sat, 12-Sep-87 09:23:07 EDT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 36