I can't seem to understand why using arr[i]!='\0'
never does all the removals it's suppose to? I've been using the similar thing as this one
/* This one is suppose to remove all the special characters & 0-9 from all entries */
void keepAlphaOnly(char line[50])
{
int i = 0, j;
for (i = 0; line[i] != '\0'; i++) {
if (line[i] < 65 || line[i] > 122 || (line[i] > 90 && line[i] < 97)) {
for (j = i; j <= strlen(line); j++) {
line[j] = line[j + 1];
}
--i;//EDIT: adjust index to avoid skipping next char
}
}
}
int main(void) {
int i, j, N;
char str[100][50];
scanf("%d\n", &N);
for (i = 0; i < N; ++i)
gets(str[i]);
for (i = 0; i < N; i++)
keepAlphaOnly(str[i]);
for (i = 0; i < N; i++)
printf("%s\n", str[i]);
return 0;
}
To remove some characters or doing sorting and searching or removal from the string but it doesn't do it for the whole string, but leaves some behind just as from the original string?