Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #define TRUE 1
- #define FALSE 0
- int main(void)
- {
- char phrase[101];
- printf("Enter phrase: ");
- fgets(phrase, 101, stdin);
- printf("%s\n", phrase);
- make_copy_of_string(phrase, phrase_copy);
- keep_chars(phrase_copy);
- conver_upper_to_lower(phrase_copy);
- if(palindromeness(phrase_copy) == TRUE)
- {
- printf("\nThe phrase: %s\n is a palindrome.\n", phrase);
- }else{
- printf("\nThe phrase: %s\n is 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_copy[i] = str[i];
- i++;
- }
- str_copy[i] = '\0';
- str[i] = '\0';
- }
- void keep_chars(char string[])
- {
- int i=0, j=0;
- while(string[i] != '\0')
- {
- if( ('A'<=string[i] && string[i] <= 'Z') || ('a'<= string[i] && string[i]<='z') )
- {
- string[j] = string[i];
- i++;
- j++;
- }else{
- i++;
- }
- } //end while loop
- string[j] = '\0';
- }
- void convert_upper_to_lower_case(char string[])
- {
- int i=0, j=0;
- while(string[i] != '\0')
- {
- if( ('A'<= string[i] && string[i] <= 'Z') )
- {
- string[i]='\0';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement