Added example 5-7. Reads input lines and stores each line in buffer named lines.
[C-Programming-Examples.git] / ex_2-5.c
blobe4772bbcfeca429aa5be03a0e1321487363185f4
1 /*
3 Returns first location of in data string where any character from test string occurs or -1 if none found.
5 */
7 #include <stdio.h>
9 int any(char test[], char data[])
11 int i,j;
13 for(i = 0; data[i] != '\0'; i++)
15 j=0;
17 while(test[j] != '\0')
19 if(test[j] == data[i]) { return i; } else { j++; }
22 return -1;
25 char test[] = "ax";
26 char data[] = "123bcx";
28 int main()
30 int ans = any(test, data);
31 printf("%d\n", ans);
32 return 0;