Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!think.com!linus!linus!maestro!shaula From: shaula@maestro.mitre.org (Shaula Doyle) Newsgroups: comp.lang.c Subject: (hopefully)simple question Keywords: bus error, book Message-ID: <1991Apr5.132443.7726@linus.mitre.org> Date: 5 Apr 91 13:24:43 GMT References: <1991Apr04.183739.4876@group1.UUCP> <15714@smoke.brl.mil> Sender: news@linus.mitre.org (News Service) Reply-To: shaula@maestro.mitre.org (Shaula Doyle) Organization: The MITRE Corporation, McLean, Va Lines: 34 Nntp-Posting-Host: maestro.mitre.org related declrations from top; struct timeval wait; struct timeval * wait_ptr; timeout is parameter, earlier write statement showed to be 10. 1 if (TRACE)printf("read and except masks set\n"); 2 if (timeout < 0) wait_ptr = 0; /* set timeout characteristics */ 3 else { 4 wait.tv_sec = timeout; /* 0 is immediate return */ 5 *wait_ptr = wait; 6 } 7 if(TRACE)printf("timeout set to %d\n",timeout); A bus error came between the two trace statements on the _second_ iteration of the loop in which this was enclosed. I changed line 5 from *wait_ptr = wait; to wait_ptr = &wait; and that fixed it. My question is: why? what was wrong? I know that a segmentation error means I tried to write outside my program address space, can someone give me an explanation of what a bus error is? I hope this isn't considered a waste of time, this seemed to me the kind of esoteric C question this group would like. FYI: I'm using cc under SunOS 4.1.1 -thanks for the time- shaula PS I regularly program in about 3 different languages, and I find I get confused on basic syntax sometimes. K&R seems to make a horrible reference for this sort of simple detail, and I was hoping someone could recommend a good alternative? thanx again. shaula@maestro.mitre.org