/* StringCopying.c (c) Kari Laitinen http://www.naturalprogramming.com/ 2013-11-25 File created. 2013-11-25 Last modification. */ #include #include int main() { char string_to_modify[] = "ABCDEFGHIJK" ; char string_to_be_copied[] = "1234567" ; int character_index ; printf( "\n Original string: %s", string_to_modify ) ; strcpy( string_to_modify, string_to_be_copied ) ; strcpy( string_to_modify, "abc" ) ; printf( "\n Modified string: %s\n", string_to_modify ) ; printf( "\n LOCATION CODE CHARACTER \n" ) ; for ( character_index = 0 ; character_index < sizeof( string_to_modify ) ; character_index ++ ) { printf( "\n %X %X %c", (long) &string_to_modify[ character_index ], ( int) string_to_modify[ character_index ], string_to_modify[ character_index ] ) ; } printf( "\n" ) ; } /* Below is a sample run of this program. As the program prints physical memory addresses of the memory area reserved to string_to_modify, the output can vary depending on the computer in which the program is run. Original string: ABCDEFGHIJK Modified string: abc LOCATION CODE CHARACTER 22FF60 61 a 22FF61 62 b 22FF62 63 c 22FF63 0 22FF64 35 5 22FF65 36 6 22FF66 37 7 22FF67 0 22FF68 49 I 22FF69 4A J 22FF6A 4B K 22FF6B 0 */