That inner while loop should be changed to an if instead. The way you have it now, it keeps matching characters in shortstr with the same character in longstr, so iii gets matched with the i in peice.
Actually, there are a number of things wrong there...
Actually, there are a number of things wrong there...
Code:
for (i = 0; longstr[i]; i++) {
if (shortstr[j] == '\0')
break; // end of shortstr
if (longstr[i] == shortstr[j])
j++; // match against the next character
}
return (shortstr[j] == '\0') // true if all of shortstr was matched, false otherwise
