Last active
August 29, 2015 14:04
-
-
Save Learath2/7670d3b12d859e5ad6af to your computer and use it in GitHub Desktop.
K&R2 Exercise 2-5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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