aboutsummaryrefslogtreecommitdiff
path: root/2.5.c
blob: 6988cfb6c0ee75003f03fd5018af880d6ae95659 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
}