Skip to content

Instantly share code, notes, and snippets.

@mgabrielmarin
Created October 31, 2025 19:10
Show Gist options
  • Select an option

  • Save mgabrielmarin/9a133b4eaf060083a6ad273b4210a31e to your computer and use it in GitHub Desktop.

Select an option

Save mgabrielmarin/9a133b4eaf060083a6ad273b4210a31e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
if (argc < 2)
fprintf(stderr, "Please provide a string\n");
const char *w = argv[1];
int i = 0;
int j = strlen(w)-1;
while (i < j) {
if (w[i] != w[j]) {
printf("Not a palindrome\n");
return 1;
}
i++;
j--;
}
printf("A palindrome\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment