Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!ncsuvx!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Re: pointer & struct Message-ID: <3321@xyzzy.UUCP> Date: 8 Feb 89 19:38:15 GMT References: <7208@pyr.gatech.EDU> Organization: Data General, RTP NC. Lines: 35 > dvu@pyr.gatech.EDU (Dinh Vu) > The small program below compiled fine, but > it gave core dump when I run it. Would someone give me > some light on this matter. In general, you should run "lint" on your programs. It will catch many simple errors, such as the one here. In this instance, lint has this to say: (12) warning: var may be used before set (14) warning: main() returns random value to invocation environment about the appended program Dinh was wondering about. It is perhaps a little cryptic, but it covers the essentials: the struct pointer was used before it was set to anything, and the program will potentially return an undefined value to its invoker. #include struct abc { int x; int y; }; main() { struct abc *var; var->x = 5; var->y = 10; } -- "Cogito, ergo spud." I think, therefore a yam. -- Wayne Throop !mcnc!rti!xyzzy!throopw