Thanks alot for the suggestion, I did not know of "isalpha", handy
It didn't do the trick though, the issue remains the same =/
As said I also don't get why whitespace function would work like a charm while Alpha one doesn't for some reason hm
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <String.h>
#define ZEICHEN 40
int s_length, i, j = 0;
char sentence[ZEICHEN];
char *poscheck;
void removeWhitespace(char *str)
{
char *ptr = str;
while (*ptr != '\0')
{
while (isspace(*ptr))
{
ptr++;
}
*str = *ptr;
str++;
ptr++;
}
}
void makeLower(char *str)
{
while (*str != '\0')
{
*str = tolower(*str);
str++;
}
}
void removeSign(char *str)
{
char *ptr = str;
while (*ptr != '\0') {
while (!isalpha(*ptr))
{
ptr++;
}
*str = *ptr;
printf("%c", *ptr);
str++;
ptr++;
}
}
int main()
{
while(1)
{
printf("palindrome\n");
printf("Enter a message: ");
fgets(sentence,ZEICHEN,stdin);
removeWhitespace(sentence);
makeLower(sentence);
removeSign(sentence);
s_length = strlen(sentence);
poscheck = sentence;
for (i = 0; i < s_length/2; i++)
{
if(!(*(sentence+i) == *(poscheck+s_length-1-i)) || (strchr(sentence, '\n')))
{
printf ("Not a palindrome");
exit(1);
}
}
printf ("Palindrome\n");
}
return 0;
}