mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-12-11 00:21:24 +01:00
feat(solutions): add prefix-suffix/c/function
This commit is contained in:
18
challenges/prefix-suffix/solutions/c/function/solution.c
Normal file
18
challenges/prefix-suffix/solutions/c/function/solution.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
#include "string.h"
|
||||
|
||||
int main() {
|
||||
char* string = input();
|
||||
char* string2 = input();
|
||||
bool is_preffix = string_starts_with(string, string2);
|
||||
bool is_suffix = string_ends_with(string, string2);
|
||||
free(string);
|
||||
free(string2);
|
||||
printf("%s\n", is_preffix ? "true" : "false");
|
||||
printf("%s\n", is_suffix ? "true" : "false");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user