For C IO we will start with a pretty basic standard IO palindrome checker. The code is listed below:
palindrome.c
#include <stdio.h>
#include <string.h>
int main(){
char text[100];
int begin, middle, end, length = 0;
gets(text);
while (text[length] != '\0')
length++;
end = length - 1;
middle = length/2;
for (begin = 0; begin < middle; begin++){
if (text[begin] != text[end]){
printf("false\n");
break;
}
end--;
}
if (begin == middle)
printf("true\n");
return 0;
}
Above is a palindrome checker written without any of the built in string functions of C, with a max string size of 100.
It will check 1 string and return true if the string is a palindrome (notice it counts spaces as part of the string so they must be mirrored to count as a palindrome), and false if it is not.
Some sample test cases:
Test 0
Input:
wow
Expected Output:
true
Test 1
Input:
mimir
Expected Output:
false
Test 2
Input:
racecar
Expected Output:
true
These are just a few samples, you can add as many as you'd like to the platform.