[Solved] Comparing two Sub-Strings of two Strings between two set positions (integer values) in C [closed]


You can use the strncmp function to compare two strings up to a maximum number of characters. To start a comparison in the middle of a string, you would pass in the address of the array element to start the comparison at.

For example:

if (strncmp(&string1[4], &string2[4], 4) == 0) {
    printf("characters 5 - 8 are the same\n");
} else {
    printf("characters 5 - 8 are not the same\n");
}

1

solved Comparing two Sub-Strings of two Strings between two set positions (integer values) in C [closed]