/* Напишите версию функции squeeze(s1, s2), которая удаляет из s1 все символы,
встречающиеся в строке s2. */
#include <stdio.h>
void squeeze (char [], char []);
int main()
{
char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
char s2[] = {"e", "o"};
squeeze (char s1[], char s2[]);
}
void squeeze (char s1[], char s2[])
{
int i; // count for s1
int j; // count for s2
int e = 0; // count for result massive
int c, d; // symbols that we compare
char result_massive[15]; // result massive
for (j = 0; j <=1; j++){
c = s2[j];
for (i = 0; i <=10; i++){
d = s1[i];
if (d != c)
result_massive[e++] = d;
}
}
printf("%s\n", result_massive);
}
Компилятор (gcc) выдает
test.c: In function ‘main’:
test.c:10:20: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:20: note: (near initialization for ‘s1’)
test.c:10:25: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:25: note: (near initialization for ‘s1’)
test.c:10:30: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:30: note: (near initialization for ‘s1’)
test.c:10:35: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:35: note: (near initialization for ‘s1’)
test.c:10:40: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:40: note: (near initialization for ‘s1’)
test.c:10:45: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:45: note: (near initialization for ‘s1’)
test.c:10:50: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:50: note: (near initialization for ‘s1’)
test.c:10:55: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:55: note: (near initialization for ‘s1’)
test.c:10:60: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:60: note: (near initialization for ‘s1’)
test.c:10:65: error: excess elements in char array initializer
10 | char s1[] = {"h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"};
| ^~~
test.c:10:65: note: (near initialization for ‘s1’)
test.c:11:20: error: excess elements in char array initializer
11 | char s2[] = {"e", "o"};
| ^~~
test.c:11:20: note: (near initialization for ‘s2’)
Гугление привело только к другим ошибкам. Заранее спасибо