Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!killer!texbell!nuchat!sugar!ficc!jair From: jair@ficc.uu.net (jair bobys) Newsgroups: comp.lang.c Subject: Re: pointer & struct Summary: Need to actually allocate a structure Message-ID: <2990@ficc.uu.net> Date: 3 Feb 89 17:15:49 GMT References: <7208@pyr.gatech.EDU> Distribution: usa Organization: Ferranti International Controls Lines: 32 In article <7208@pyr.gatech.EDU>, dvu@pyr.gatech.EDU (Dinh Vu) writes: > I am learning C, and having difficulty with pointers, and structures > [some text deleted] > main() > { > struct abc *var; > > var->x = 5; > var->y = 10; > } The problem is that you never allocated a structure for your pointer to point to. Try: main() { struct abc *var, place; var = place; var->x = 5; var->y = 10; } You were trying to assign values to nonexistent locations, hence the core dump. -- +------------------------------------------------------------------------------+ |"One ring to bring them all | Jair Bobys (713) 274-5201 | | and in the darkness bind them." | uunet!ficc!jair jair@ficc.uu.net| +------------------------------------------------------------------------------+