/* StringFunctionsMore.c (c) Kari Laitinen http://www.naturalprogramming.com/ 2013-11-24 File created. 2013-11-24 Last modification. */ #include #include int main() { char first_string[] = "AAABBBCCCDDD" ; char second_string[] = "xxxyyyzzz" ; printf( "\n Original first_string : %s", first_string ) ; printf( "\n Original second_string : %s", second_string ) ; strncpy( first_string, second_string, 5 ) ; printf( "\n Modified first_string : %s", first_string ) ; if ( strncmp( first_string, second_string, 5 ) == 0 ) { printf( "\n The first 5 characters in both strings are the same." ) ; } if ( strstr( first_string, "CCCD" ) ) { printf( "\n String \"%s" "\"includes string \"CCCD\" in index position %d.\n", first_string, strstr( first_string, "CCCD" ) - first_string ) ; } }