kelley@qucis.queensu.CA (Todd Kelley) (07/19/90)
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 <stdio.h> 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)