Pointers seem complicate. But you have to believe that pointers were designed to make things simpler. In this problem, you will see how pointers simplified the parameters for a function call.
A palindrome is a string that is identical to its reverse, like "level" or "aba". In this problem, some strings are given, and the longest palindrome in each string should be reported.
You have to implement a function in the following format:
| int palindrome_test( const char *str, int length ) ; |
Given a string *ptr and its length, the function returns the length if the string is a palindrome; otherwise, it returns 0. A single character is also a palindrome. The "const" here is to avoid modification in *str.
The program will print the longest palindrome that appears first, and this will be done in the main function we provided.
The input consists of several lines of input. Each line presents a test case, and its length less than 128. Any empty lines should be skipped. There are not more than 20 valid lines in a input.
For each valid test case, print the longest palindrome that was first found.