From c24973af02bc33f2f5f25d37e22ca91da5de3c47 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 4 Jun 2022 12:11:15 +0530 Subject: inital commit --- 2.5.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 2.5.c (limited to '2.5.c') diff --git a/2.5.c b/2.5.c new file mode 100644 index 0000000..6988cfb --- /dev/null +++ b/2.5.c @@ -0,0 +1,32 @@ +#include + +/* function to delete each character in str1 that matches with str2 */ +int any(const char s1[], const char s2[]); + +int +main(void) +{ + char str[] = "ok chud you win this time"; + char del[] = "ic"; + + printf("%d\n", any(str, del)); + + return 0; +} + +int +any(const char s1[], const char s2[]) +{ + int i, j; + + for (i = 0; s1[i] != '\0'; i++) { + + for (j = 0; s2[j] != '\0'; j++) + if (s2[j] == s1[i]) + return i+1; + + } + + return -1; +} + -- cgit v1.2.3