First thing:
1. You cant define functinos within functions, its not allowed in C / C++.
2.
int main(void)
{
char palindrome[80];
int ispalindrome=1;/*boolean value True*/
int i=0;
int j=0;
/* get the user input */
do{
printf("Enter a string no more than 80 characters ");
fgets(palindrome,80,stdin);
// call remove_newline () function here
j = strlen(palindrome) - 1;
i = 0;
//////////The below one is a function !!!!///////////////////////
// you need to place it out of main( ) and then call it in main
// with the argument palindrome. Better name the string variable
// palindrome to "input" or "my_string" to avoid confusion.
/* Remove the trailing newline*/
void remove_newline( char* palindrome ){
char* p = 0 ;
if( p = strrchr( palindrome, '\n' ) )
*p = '\0' ;
}
/////////////////////////////////////////////////////////////
int string_length=strlen(palindrome);
if(palindrome[string_length-1]=='?'||palindrome[string_length-1]=='!'
||palindrome[string_length-1]=='.'){
/*If the last character is a ?,!or . continue with normal operation*/
j=string_length-1;
i = 0;
// this part is unnecessary since fgets() makes sure you dont
// accept more than 80 chars from the user.
if(j>80){
/*finds out if characters or more than 80*/
printf("Error your characters cannot be more than 80");
}
////////////////////
// create a seperate function named palindrome rather than
// doing all the things in main ( ) itself.
while((i <= j && ispalindrome && isalpha(i) && isalpha(j) )){
if(tolower (palindrome[i]) != tolower(palindrome[j])) {
ispalindrome = 0;
}
i++;
j--;
}
if(ispalindrome) {
printf("%s is a palindrome!\n", palindrome);
}
else {
printf("sorry, %s is not a palindrome\n", palindrome);
}
}
else
printf("Your input must be terminated by a punctuation mark");
}
}while(j>80);
return 0;
}
Also do read the link I had posted previously because it contains each and every step on how to preform the palindrome check.
Make updates and repost.