I need help with my program in C. My task is too remove all characters which are not letters and change every first letter of a word to capital letter and return the number of deleted non-letters, for example "i love programming!" to "ILoveProgramming", it should prop return 3 (number of deleted non letters) . I cannot use the <ctype.h>, <stdlib.h> or <string.h>headers,[]only to declare array, and I can only use numbers1and0. Also I can't change the function definition or do anything with that (int message_compression(char * txt);`). So far I managed to change letters but I have no idea how to remove characters which are not letters.
#include <stdio.h>
#include <math.h>
int message_compression(char* txt);
int main() {
char txt[1001];
char *wt;
wt = txt;
puts("Text:");
fgets(txt, 1001, stdin);
message_compression(wt);
int i = 0;
printf("After change:\n");
while (*wt != '\0') {
printf("%c", *wt);
i++;
*wt = *(wt + i);
}
return 0;
}
int message_compression(char* txt) {
if (txt == NULL) {
return -1;
}
int i = 0;
while (*(txt + i) != '\x0') {
if (i == 0) {
*(txt + i) = *(txt + i) - ' ';
}
if (*(txt + i) == ' ' || *(txt + i) == ',' || *(txt + i) == '.') {
if (*(txt + i + 1) != ' ' && *(txt + i + 1) != ',' && *(txt + i + 1) != '.') {
*(txt + i + 1) = *(txt + i + 1) - ' ';
}
}
i++;
}
return 0;
}