I have an array declared like so:
char *array[4];
which is populated by a different function with strings, i.e. ["one", "two", "three", "four"].
My goal is to copy this array into a new array, excluding the last two elements, so new_array would contain ["one", "two"].
This is what I have tried so far:
int *new_array[2];
for (int i = 0; i < 2; i++){
strncpy(new_array[i], array[i], strlen(array[i]));
}
But have received the following warning:
warning: passing argument 1 of ‘strncpy’ from incompatible pointer type [-Wincompatible-pointer-types]
note: expected ‘char * restrict’ but argument is of type ‘int *’
extern char *strncpy (char *__restrict __dest,