#include <stdlib.h>
int main(int argc, char** argv) {
int value;
int array[5] = {1, 1, 1, 2, 3};
int size = 5;
scanf("%d", &value);
for (int i = 0; i < size; i++) {
if (value == array[i]) {
for (int j = i; j < size; j++) {
array[j] = array[j + 1];
size--;
}
}
}
for (int i = 0; i < size; i++) {
printf("%d ", array[i]);
}
}
Example I have array: 1, 1, 1, 2, 3 and user inputs value = 1, my code must delete all number value = 1 in array. But when my code run this case, the output is: 1, 2
which should be is: 2, 3.