diff options
author | sinanmohd <pcmsinan@gmail.com> | 2022-06-18 09:52:07 +0530 |
---|---|---|
committer | sinanmohd <pcmsinan@gmail.com> | 2022-06-18 09:52:07 +0530 |
commit | 319b26046b33b5dcc1b6f3ea18a53be81c4d0e2e (patch) | |
tree | e86217b305140f143473ac64bfa721d2ac833f48 | |
parent | b5a845047dcad4512407ba7ee39779093cf38fc2 (diff) |
5.4
-rw-r--r-- | 5.4.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +#include <stdio.h> +#include <string.h> + +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; +} |