Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!rochester!PT!ius1.cs.cmu.edu!edw From: edw@ius1.cs.cmu.edu (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: Need help with structure pointers Message-ID: <1051@ius1.cs.cmu.edu> Date: Sat, 10-Oct-87 17:28:17 EDT Article-I.D.: ius1.1051 Posted: Sat Oct 10 17:28:17 1987 Date-Received: Mon, 12-Oct-87 18:47:12 EDT References: <1778@killer.UUCP> Organization: Carnegie-Mellon University, CS/RI Lines: 45 In article <1778@killer.UUCP>, tad@killer.UUCP (Tad Marko) writes: > I've never bothered to get a complete grasp over structures before, and > now it is hurting me. Could someone please tell me the proper way to > accomplish the following ugliness? > > ----------------- Corrected program to follow: struct X { char *s; int a, b; }; main() { struct X x; struct X *sp; char max[25]; sp = &x; /* sp.s = max; */ sp->s = max; strcpy(x.s, "Some Stuff"); fun(&x); } fun(stuff) struct X *stuff; { /* stuff->*(++s) = 'X'; */ *(++stuff->s) = 'X'; printf("%s\n", stuff->s); /* I want this to print "Xme Stuff" */ } -- Eddie Wyatt e-mail: edw@ius1.cs.cmu.edu