Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!island!hue From: hue@island.COM (Pond Scum) Newsgroups: comp.unix.wizards Subject: Re: Socket datagram again. Message-ID: <4065@island.COM> Date: 18 May 91 00:54:20 GMT References: <11242@hub.ucsb.edu> Sender: usenet@island.COM Followup-To: comp.lang.c Organization: Island Graphics Corp., San Rafael, CA Lines: 22 In article <11242@hub.ucsb.edu> hubert@spica.ucsb.edu writes: >But when I tried the following program(which could be wrong. I am a rooky.) > I found out that if I don't add exit(0) at the end of the program. The >a.out will give me segment fault. Whay is that? Please take these questions to comp.lang.c. This isn't the group for it. Or better yet, try to find someone locally who can answer your questions. >struct record >{ > int from; > int to[10]; >} > >main() You've just declared main as a function that returns struct record. Put a semicolon after the curly brace. You're trashing the stack which causes the seg fault when you return from main. By calling exit you avoid returning from main with a trashed stack. -Jonathan hue@island.COM