Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main () {
- int n = 15, m = 10;
- char *s1 = malloc(n*sizeof(char));
- char *s2 = malloc(m*sizeof(char));
- char c1;
- char c2;
- int i = 0;
- int k = 0;
- while (c1 != '\n') {
- scanf("%c", &c1);
- s1[i] = c1;
- ++i;
- }
- while (c2 != '\n') {
- scanf("%c", &c2);
- s2[k] = c2;
- ++k;
- }
- for(int j=0; s1[j]!='\n'; j++) {
- printf("%c", s1[j]);
- }
- for(int j=0; s2[j]!='\n'; j++) {
- printf("%c", s2[j]);
- }
- int index = -1;
- for(int i1=0; s1[i1]!='\n'; i1++) {
- for (int j1 = i1, k1=0; s2[k1]!='\n' && s1[j1]==s2[k1]; j1++, k1++) {
- if(k1>0 && s2[k1]=='\n')
- {
- index = i1;
- break;
- }
- }
- }
- printf("%d", index);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement