Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!xanth!mcnc!rti!sunpix!matthew From: matthew@sunpix.UUCP ( Sun NCAA) Newsgroups: comp.lang.c Subject: Re: pointer & struct Message-ID: <385@greens.UUCP> Date: 3 Feb 89 15:11:11 GMT References: <7208@pyr.gatech.EDU> Distribution: usa Organization: Sun Microsystems, Research Triangle Park, NC Lines: 41 In article <7208@pyr.gatech.EDU>, dvu@pyr.gatech.EDU (Dinh Vu) writes: @ I am learning C, and having difficulty with pointers, and @ structures. The small program below compiled fine, but @ it gave core dump when I run it. Would someone give me @ some light on this matter. @ @ @ #include @ @ struct abc { @ int x; @ int y; @ }; @ @ main() @ { @ struct abc *var; @ @ var->x = 5; @ var->y = 10; @ } @ @ @ @ Dinh Vu Okay, I think I've got your problem figured out. What I see is a structure named 'abc'. Next I see the declaration of a pointer to point to a structure of type 'abc'. Next I see two structure pointer operations trying to initialize elements of a structure, but no were do I see the definition of the structure being pointed to. Basically what I'm saying, is that your structure pointer is not being initialized to point to a structure of type 'abc'. -- Matthew Lee Stier (919) 469-8300| Sun Microsystems --- RTP, NC 27560| "Wisconsin Escapee" uucp: {sun, rti}!sunpix!matthew |