pointer & struct

Sun NCAA matthew at sunpix.UUCP
Sat Feb 4 01:11:11 AEST 1989


In article <7208 at pyr.gatech.EDU>, dvu at pyr.gatech.EDU (Dinh Vu) writes:
@ I am learning C, and having difficulty with pointers, and
@ structures.  The small program below compiled fine, but
@ it gave core dump when I run it.  Would someone give me 
@ some light on this matter.
@ 
@ 
@ 	 #include <stdio.h>
@ 	
@ 	struct abc {
@ 		int x;
@ 		int y;
@ 	};
@ 
@ 	main()
@ 	{
@ 		struct abc *var;
@ 
@ 		var->x = 5;
@ 		var->y = 10;
@ 	}
@ 
@ 
@ 
@ Dinh Vu


    Okay, I think I've got your problem figured out. What I see is a structure
named 'abc'. Next I see the declaration of a pointer to point to a structure of
type 'abc'. Next I see two structure pointer operations trying to initialize
elements of a structure, but no were do I see the definition of the structure
being pointed to. 

    Basically what I'm saying, is that your structure pointer is not being 
initialized to point to a structure of type 'abc'.


-- 
Matthew Lee Stier     (919) 469-8300|
Sun Microsystems ---  RTP, NC  27560|          "Wisconsin   Escapee"
uucp: {sun, rti}!sunpix!matthew     |



More information about the Comp.lang.c mailing list