Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!necntc!linus!mbunix!jfjr From: jfjr@mitre-bedford.ARPA (Jerome Freedman) Newsgroups: comp.lang.c Subject: Arrays and structures Message-ID: <22151@linus.UUCP> Date: 19 Jan 88 20:12:22 GMT Sender: news@linus.UUCP Reply-To: jfjr@mbunix (Freedman) Organization: The MITRE Corporation, Bedford, Mass. Lines: 57 Suppose I have the following typedef struct /* I despise structure tags */ { /* some irrelevant field declarations */ char string[80]; int vector [4]; } structure_type; structure_type first_structure,second_structure; /* The various fields of first_structure get filled */ /* and somewhere in the code I do this */ second_structure = first_structure; /* ANSI standard allows this */ Now, tell me about the string and vector fields of second structure. Since they are arrays then the fields are actually pointers. The question is: are the string and vector fields of "second_structure" pointing ad the same addresses as the corresponding fields of first structure or are they pointing to different areas of memory into which the contents of the arrays pointed to in first_structure have been copied(whew - what I meant not what I said)?? Is the situation different if I change the type declaration to typedef struct /* I despise structure tags */ { /* some irrelevant field declarations */ char *string; int *vector; } structure_type; structure_type first_structure,second_structure; then I say first_structure.string = "some string"; second_structure = first_structure; Jerry Freedman, Jr "Thank you, folks, jfjr@mitre-bedford.arpa for those kind applause" (617)271-4563 Jerry Freedman, Jr "Love is staying up all night jfjr@mitre-bedford.arpa with a sick child, (617)271-4563 or a healthy adult"