[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why the hell is my code coredumping ?



On 6 Feb 2002, Artur Grabowski wrote:

> Marc Xander Makkes <xander@kr85.org> writes:
>
> > I have this little code;
> >
> > +----
> >
> >
> > #include <stdio.h>
> >
> > struct point { int x; int y;};
> > int main()
> > {
> > struct point *p;
> > p->y = 13;
> > printf("%d\n", p->y);
> > }
> >
> >
> > ----+
> >
> > it compiles and runs ok on solaris, and it compiles ok on openbsd but
> > when i run it, it directly core dumpes. Is there something i forgot to
> > read or is it the 13?:)
> >
> > The code is compiled on 2 differend OpenBSD 3.0 machines, one with GENERIC
> > and one modified, both i386.
> >
> >
> > any clues ?
>
> There is a great book written by two guys, Kernighan and Ritchie. It's
> called "The C Programming Language". It answers your question.
>

For you information this little code came out of The C programing language
( ansii c ) by brian w. kernighan and dennis m. ritchie. That was made in
1988.

> I could give you a better answer to your question, but that would be
> counter-productive, because you'd just continue to make the next beginners
> mistake and ask again.
>
> Hint: what does the '*' mean. And what is 'p' initialized to.
>
> //art