From 319b26046b33b5dcc1b6f3ea18a53be81c4d0e2e Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 18 Jun 2022 09:52:07 +0530 Subject: 5.4 --- 5.4.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 5.4.c diff --git a/5.4.c b/5.4.c new file mode 100644 index 0000000..a8ae1c4 --- /dev/null +++ b/5.4.c @@ -0,0 +1,33 @@ +#include +#include + +int strend(char *to, char *from); + +int +main(void) +{ + char str[] = "gnu linux"; + + if(strend(str, "ux")) + printf("yeahoooo\n"); + + return 0; +} + +int +strend(char *to, char *from) +{ + size_t fsize = strlen(from); + size_t tsize = strlen(to); + + if (tsize > fsize) + to += tsize - fsize; + else + return 0; + + + while (*to++ == *from++ && *to != '\0' && *from != '\0') + ; + + return (*from == '\0') ? 1 : 0; +} -- cgit v1.2.3