Last active
December 1, 2016 12:14
-
-
Save iamarkdev/4ba07a8357075d93b26e89b65cc9f7e3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
// return the index of the first occurrence of any character in matching occuring in string. -1 if none. | |
int any(char string[], char matching[]) { | |
for (int i = 0; string[i] != '\0'; i++) { | |
for (int j = 0; matching[j] != '\0'; j++) { | |
if (string[i] == matching[j]) { | |
return i; | |
} | |
} | |
} | |
return -1; | |
} | |
int main() { | |
printf("%d\n", any("this is a test yo", "y")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment