The program needs to tell me if the phrase is a palindrome or not but when compile it and then enter a phrase it tells me everything is a palindrome..something is wrong with my functions but I cannot figure out what it is. I need some help please lol
Code:
#include <stdio.h>
#define true 1
#define false 0
void make_copy_of_string(char str[], char str_copy []);
void keep_chars(char str[]);
void convert_upper_to_lower_case(char str[]);
_Bool palindromeness(char str[]);
int main(void)
{
char phrase[101], phrase_copy[101];
printf("Enter Phrase: ");
fgets(phrase, 101, stdin);
make_copy_of_string(phrase, phrase_copy);
keep_chars(phrase_copy);
convert_upper_to_lower_case(phrase_copy);
if(palindromeness(phrase_copy) == true)
printf("The phrase: %s\n Is a palindrome!\n", phrase);
else
printf("The phrase: %s\nIs not a palindrome\n", phrase);
return 0;
}
void make_copy_of_string(char str[] , char str_copy[])
{
int i=0;
while(str[i]!= '\n' && str[i] != '\0')
{
str[i] = str_copy[i];
i++;
}
str_copy[i]='\0';
str[i]='\0';
}
void keep_chars(char str[])
{ int i=0, j=0;
while(str[i] != '\0')
{
if(('A' <= str[i] && str[i] <= 'Z') || ('a' <= str[j] && str[j] <='z'))
{
str[i]=str[j];
i++;
j++;
}
else
{
i++;
}
}
str[j]='\0';
}
void convert_upper_to_lower_case(char str[])
{
int i=0;
while(str[i] !='\0')
{
if('A' <= str[i] && str[i] <= 'Z')
{str[i]=str[i]+32;
i++;
}
else
{
i++;
}
}
}
_Bool palindromeness(char str[])
{
int i=0;
char str_copy[i];
if(str[i] == str_copy[i])
{
return true;
}
else
{
return false;
}
}