void printArray(const char *name, const int arr[], size_t count) {
printf("%s is {", name);
for (size_t i = 0; i < count; i++) {
if (i > 0) {
printf(", ");
}
printf("%d", arr[i]);
}
printf("}\n");
}
int numbers[] = {2, 3, 5, 7, 11};
size_t count = sizeof numbers / sizeof numbers[0];
//C has no slices. A part without copying is a pointer
//into the array and the number of elements
const int *last3 = numbers + 2;
size_t last3Count = count - 2;
//last3 is {5, 7, 11}
//a part as a copy
int first2[2];
memcpy(first2, numbers, sizeof first2);
//first2 is {2, 3}
printArray("first2", first2, 2);
printArray("last3", last3, last3Count);
//the pointer sees changes in the array, the copy does not
numbers[0] = 20;
numbers[2] = 50;
//first2 is {2, 3}, last3 is {50, 7, 11}
printArray("first2", first2, 2);
printArray("last3", last3, last3Count);