Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!decvax!ucbvax!sdcsvax!ucsdhub!jack!man!nusdhub!rwhite From: rwhite@nusdhub.UUCP (Robert C. White Jr.) Newsgroups: comp.lang.c Subject: Re: Need help with structure pointers Message-ID: <120@nusdhub.UUCP> Date: Mon, 12-Oct-87 18:01:14 EDT Article-I.D.: nusdhub.120 Posted: Mon Oct 12 18:01:14 1987 Date-Received: Wed, 14-Oct-87 05:30:29 EDT References: <1778@killer.UUCP> Organization: National University, San Diego Lines: 19 Summary: Use -> not . In article <1778@killer.UUCP>, tad@killer.UUCP (Tad Marko) writes: The only problem I saw in you posted program is that when you have a pointer to a structure you were not de-refrenceing the pointer before reaching for the value. You need something like (*structname).fieldname to do this. The shorthand for this is the -> operator, therefore where sp and stuff were defined as "struct X *sp, *stuff" you need to change the lines as follows: > sp.s = max; sp->s = max; > printf("%s\n", stuff.s); /* I want this to print "Xme Stuff" */ printf("%s\n", stuff->s); /* I want this to print "Xme Stuff" */ Disclaimer: o-god-please-don't-let-me-be-wrong.... Robert.