diff options
author | sinanmohd <pcmsinan@gmail.com> | 2022-06-04 12:11:15 +0530 |
---|---|---|
committer | sinanmohd <pcmsinan@gmail.com> | 2022-06-04 12:11:15 +0530 |
commit | c24973af02bc33f2f5f25d37e22ca91da5de3c47 (patch) | |
tree | 460a005b6a3a9a967bd881bc2bf01e0becbe33cc /2.5.c |
inital commit
Diffstat (limited to '2.5.c')
-rw-r--r-- | 2.5.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ +#include <stdio.h> + +/* 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; +} + |