How to check if string is palindrome ignore case in C

2 Answers

0 votes
#include <string.h>
#include <stdio.h>

int main(void)
{
    char string[] = "saw aibohphobia WAS";

    int result = _stricmp(string, _strrev(_strdup(string)));

    if (result == 0)
        puts("palindrome");
    else
        puts("not palindrome");

    return 0;
}




/*
run:

palindrome

*/

 



answered Apr 6, 2022 by avibootz
edited Dec 28, 2023 by avibootz
0 votes
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    char string[] = "saw aibohphobia WAS";

    char* p = _strdup(string);
    int result = _stricmp(string, _strrev(p));
    free(p);

    if (result == 0)
        puts("palindrome");
    else
        puts("not palindrome");

    return 0;
}




/*
run:

palindrome

*/

 



answered Nov 12, 2022 by avibootz
edited Dec 28, 2023 by avibootz
...