the issue i have is that the code keeps adding letters after the 'for' code, if i write "ni pratar bra latin" it will become "nipratarbralatintin" with an exta "tin"
int ret1;
int size = 0;
int i = 0;
char ch[100];
printf("WELCOME USER\n");
printf("ENTER A SENTENCE OR A WORD FOR THE PROGRAM TO START.\n");
printf("THE PROGRAM WILL CHECK IF YOUR SENTENCE / WORD IS A PALENDROME");
printf("\n");
scanf(" %[^\n]s", &ch);
Removes spaces aka the part im having issues with
for (i = 0, size = 0; i < strlen(ch); i++) {
ch[i - size] = ch[i];
if (ch[i] == ' ')
size++;
}
ch[i] = '\0';
ret1 = isPalindrome(ch);
int quit;
if (ret1 == 1)
// 1 means string is palendrome
printf("\nYOUR SENTENCE/WORD: %s IS A PALENDROME", ch);
else if (ret1 == 0)
// 0 means string is not palendrome
printf("\nYOUR SENTENCE/WORD: %s IS NOT A PALENDROME", ch);