Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- bool isInMultiple(char *word1, char *word2){
- int count =0;
- char *temp = word1;
- for (int i=0;i<strlen(word1);i++){
- if (strncmp(&temp[i], word2, 3) == 0)
- count++;
- if (count >=2)
- return true;
- }
- return false;
- }
- int main (){
- char *word1 = "rskrskrsk";
- char word2 [4] = {0};
- char* checkedStrings = {0};
- char *temp = word1;
- char char1, char2, char3;
- int count =0;
- for (int i = 0; i < (strlen(word1)-3); ++i){
- count = 0;
- strncpy(word2, &temp[i], 3);
- word2[3] = '\0';
- temp = word1;
- if (!strncmp(checkedStrings, word2, 3)) {
- printf("Test\n");
- if ( isInMultiple(word1, word2)){
- printf("%s\n", word2);
- strcat(checkedStrings, word2);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement