Aucbvax.5450 fa.unix-wizards utzoo!decvax!ucbvax!unix-wizards Fri Dec 11 19:35:51 1981 char arrays >From decvax!duke!rjf@Berkeley Fri Dec 11 19:28:56 1981 I've been reading the current discussions about the difference between char foo[] and char *foo with considerable interest. I have encountered a somewhat similar problem lately. What happens if you declare char foo[25] in a structure definition and then define an array of these structures? I did this, lint never complained, the compiler never said a word, BUT I got bus errors and illegal instruction errors when I ran the program. I seemed to also being destroying the stack, making adb harder to use. I changed the definition to char *foo in the structure definition and in the beginning of the program called malloc to allocate the needed amount of space for each character string for each element of the array of structures. (Messy!) This time the program worked smoothly! Is the space for the char array really allocated when the space for the structure is allocated or is space for a POINTER allocated as part of the structure. This, I believe, is the real question. Does anyone out there have any ideas on this? ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.