Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int find(char first_string[], char second_string[])
- {
- for (int i = 0; i < strlen(first_string); i++)
- {
- int j;
- for (j = 0; j < strlen(second_string); j++)
- {
- if (first_string[i + j] != second_string[j])
- {
- break;
- }
- }
- if (j == strlen(second_string))
- {
- return i;
- }
- }
- return -1;
- }
- int main()
- {
- char key[20] = "YoonA";
- char code[50] = "I love YoonA a lot";
- int where_is_it;
- where_is_it = find(code, key);
- cout << where_is_it;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement