#include <stdio.h>
#include <string.h>
int main()
{
char str1[80] = "downtown", str2[20] = "town";
int len1 = 0, len2 = 0, i, j, count;
len1 = strlen(str1);
len2 = strlen(str2);
for (i = 0; i <= len1 - len2; i++) {
for (j = i; j < i + len2; j++) {
count = 1;
if (str1[j] != str2[j - i]) {
count = 0;
break;
}
}
if (count == 1) {
break;
}
}
if (count == 1) {
printf("True");
} else {
printf("False");
}
}
In the above code, I'm trying to solve this one without using string functions apart from strlen() which can be replaced with a simple while loop. Is there any other way of checking for consecutive characters like firstly checking if the character is in the string, and if the i index is in the next position and not randomly in the string.
str?