mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
feat(solutions): add is-palindrome/c/function
This commit is contained in:
18
challenges/is-palindrome/solutions/c/function/solution.c
Normal file
18
challenges/is-palindrome/solutions/c/function/solution.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "character.h"
|
||||
#include "input.h"
|
||||
#include "string.h"
|
||||
|
||||
int main() {
|
||||
char* string = input();
|
||||
string = string_to_upper(string);
|
||||
string = string_replace(string, ' ', '\0');
|
||||
bool is_palindrome = string_is_palindrome(string);
|
||||
free(string);
|
||||
printf("%s\n", is_palindrome ? "true" : "false");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user