aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <pcmsinan@gmail.com>2022-06-18 09:52:07 +0530
committersinanmohd <pcmsinan@gmail.com>2022-06-18 09:52:07 +0530
commit319b26046b33b5dcc1b6f3ea18a53be81c4d0e2e (patch)
treee86217b305140f143473ac64bfa721d2ac833f48
parentb5a845047dcad4512407ba7ee39779093cf38fc2 (diff)
5.4
-rw-r--r--5.4.c33
1 files changed, 33 insertions, 0 deletions
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 <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;
+}