Code:
for (j = 0; j < i; j++)
result[j] = source[j];
These lines copy "source" into "result" up to the specified cut-off point.
Code:
while (source[j + remove] != '\0')
{
result[j] = source[j + remove];
j++;
}
These lines copy the skipped over section of "source" to the end of "result" - the loop will terminate before the null character is copied.
Code:
while (result[k] != '\0')
{
source[k] = result[k];
k++;
}
These lines depend upon the null character existing in the "result" array, but the null character was never actually copied into that array.
You need to add the null character to the "result" array after the first "while()" loop.
Code:
void removeString (char source[], int i, int remove)
// "i" is where to start removing (from findString) and "remove" is # of characters
// to remove
{
char result[81];
int j;
int k = 0;
for (j = 0; j < i; j++)
result[j] = source[j];
while (source[j + remove] != '\0')
{
result[j] = source[j + remove];
j++;
}
result[j] = '\0'; // 'j' was already incremented, so it's already in the
// correct position to place the null character
while (result[k] != '\0')
{
source[k] = result[k];
k++;
}
source[k] = '\0';
}