Skip to content

Instantly share code, notes, and snippets.

@emadflash
Last active June 26, 2021 04:11
Show Gist options
  • Save emadflash/20049ecef2889bcf69f784258f3cde3c to your computer and use it in GitHub Desktop.
Save emadflash/20049ecef2889bcf69f784258f3cde3c to your computer and use it in GitHub Desktop.
fykin pallindromes
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
int is_pallindrome(char* string, size_t len) {
char* begin = string;
char* end = string + len - 1;
int checking = len / 2;
while(end != begin && checking-- != 0) {
if (*end != *begin) {
return -1;
}
end--;
begin++;
}
return 0;
}
int main() {
char* string = "ieaeaaei";
if (is_pallindrome(string, strlen(string)) < 0) {
printf("not pallindrome");
} else {
printf("pallindrome");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment