Last active
September 2, 2019 15:08
-
-
Save jstaursky/71c95dffb824667582b8cca9e2250800 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdbool.h> | |
#include <string.h> | |
bool palendrome (char* const word) | |
{ | |
size_t len = strlen (word); | |
char *start = word, | |
*end = start + len - 1; | |
while (memcmp (start, end, 1) == 0 && start++ < end--) | |
continue; | |
if (start > end) | |
return true; | |
else | |
return false; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
if (palendrome (argv[1])) | |
puts ("true"); | |
else | |
puts ("false"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment