gcc 4.4.4 c89
warning assignment makes integer from pointer without a cast
**devices = device_buff;
warning: value computed is not used
*devices++;
I get the above warnings with the code below. What I am trying to do is get an input from the user. And assign that char array to an array of pointers. So my array of pointers will contain all the devices entered. However, I am getting a UB on this line:
**devices = device_buff;
Many thanks for any advice,
static void device_input()
{
#define DEVICE_SIZE 80
char device_buff[DEVICE_SIZE] = {0};
char **devices = NULL;
size_t i = 0;
for(i = 0; i < 3; i++) {
printf("Enter device name: ");
fgets(device_buff, (size_t)DEVICE_SIZE, stdin);
**devices = device_buff;
*devices++;
}
/* NULL terminate last element */
*devices = NULL;
printf("Display devices\n");
while(*devices != NULL) {
printf("Device [ %s ]\n", *devices++);
}
}
You must use dynamic or predefined allocation for your Buffer-ARRAY.
The Endmarker in the example is an empty String not a NULL-Pointer.