Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int i = 0, k = 0;
- char n, s;
- char *arr = malloc(sizeof(char));
- char *arr2 = malloc(sizeof(char));
- while (n!= '\n') {
- scanf("%c", &n);
- i++;
- arr = realloc(arr, i*sizeof(char));
- arr[i-1] = n;
- }
- while (s!= '\n') {
- scanf("%c", &s);
- k++;
- arr2 = realloc(arr2, i*sizeof(char));
- arr2[i-1] = s;
- }
- //printf("i = %d\n", i);
- //printf("k = %d\n", k);
- for (int j = 0; j < i-1; j++) {
- for (int l = 0; l < k-1; l++) {
- if (arr[j+l] == arr2[l]) {
- //printf("%c\n", arr[j+l]);
- //printf("%c\n", arr2[l]);
- if (l==k-2)
- printf("j = %d", j);
- } else {
- continue;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement