Created
October 8, 2015 01:34
-
-
Save asterwolf/7532bba36fd025430bc6 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
int findMatchingChars(char *string1, char *string2, char *outString){ | |
int matchFound = 0; | |
while(*string1 && *string2){ | |
if(*string1 == *string2){ | |
outString[matchFound++] = *string1; | |
} | |
++string1; | |
++string2; | |
} | |
outString[matchFound] = 0; | |
return matchFound; | |
} |
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
int findMatchingChars(char *string1, char *string2, char *outString); | |
#include <stdio.h> | |
int main(int argc, char**argv){ | |
char outString[30]; | |
int count; | |
if(argc <= 2){ | |
printf("Usage: matchCharsMain string1 string2"); | |
} | |
else{ | |
count = findMatchingChars(argv[1], argv[2], outString); | |
printf("%s %d", outString, count); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment