Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <math.h>
- int str_compare(char first[], char second[])
- {
- int i = 0;
- int key = 0;
- char first_char, second_char;
- if (strlen(first) != strlen(second))
- {
- key = -1;
- return key;
- }
- for (; i < (int)strlen(first); i++)
- {
- if (!((first[i] >= 97) && (second[i] >= 97)))
- {
- if ((first[i] >= 97) && (first[i] <= 122))
- first_char = first[i] - 32;
- else
- first_char = first[i];
- if ((second[i] >= 97) && (second[i] <= 122))
- second_char = second[i] - 32;
- else
- second_char = second[i];
- }
- else
- {
- first_char = first[i];
- second_char = second[i];
- }
- if (first_char != second_char)
- {
- key = -1;
- return key;
- }
- }
- return key;
- }
- int main()
- {
- char string[100];
- char slovo[100];
- char*h;
- int counter = 0;
- gets(string);
- gets(slovo);
- h = string;
- h = strtok(h, " ");
- while (h != NULL)
- {
- if (!str_compare(h, slovo))
- counter++;
- h = strtok(NULL, " ");
- }
- printf("%d", counter);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement