Skip to content

Instantly share code, notes, and snippets.

@Learath2
Last active August 29, 2015 14:04
Show Gist options
  • Save Learath2/7670d3b12d859e5ad6af to your computer and use it in GitHub Desktop.
Save Learath2/7670d3b12d859e5ad6af to your computer and use it in GitHub Desktop.
K&R2 Exercise 2-5
/*K&R Exercise 2-5 "any"*/
#include <stdio.h>
int any(char[], char[]);
int main()
{
char s1[64] = "Test Tekt Takt";
char s2[10] = "ke";
printf("%d\n", any(s1, s2));
}
int any(char s1[], char s2[])
{
int n, i, j;
n = -1;
for(i = 0; n < 0 && s1[i] != '\0'; i++)
for(j = 0; s2[j] != '\0'; j++)
if(s1[i] == s2[j])
n = i;
return n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment