Path: utzoo!utgpu!news-server.csri.toronto.edu!qucis!kelley From: kelley@qucis.queensu.CA (Todd Kelley) Newsgroups: comp.unix.questions Subject: dbx treats &(array[0]) differently from array when length is odd Keywords: dbx odd array length Message-ID: <805@qusunc.queensu.CA> Date: 18 Jul 90 22:57:22 GMT Organization: Queen's University, Kingston, Ontario, Canada Lines: 38 Hello unix experts. I'm puzzled by dbx -- it gives different results for the command "print array" than it gives for "print &(array[0])" on a SUN4. If the size of the array is odd, the first character of the string is ommitted. The problem goes away if the length of the array is even. Is this an alignment problem? Here is the offending C program, and an excerpt from a dbx session: ______________________________________________ #include typedef struct { char my_string[9]; }elem_type; main() { elem_type my_element; strcpy(my_element.my_string,"abc"); printf(my_element.my_string); printf("\n"); } ______________________________________________ stopped in main at line 10 in file "test.c" 10 printf(my_element.my_string); (dbx) print my_element.my_string my_element.my_string = "bc" (dbx) print &(my_element.my_string[0]) &my_element.my_string[0] = 0xf7fffd34 "abc" (dbx) cont abc execution completed, exit code is 0 program exited with 0 (dbx) quit If you can explain this behaviour, please send email to me. Todd Kelley (kelley@qucis.queensu.ca)