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'm trying to do is get input from the user. And assign this char array to an array of pointers. Therefore, my array of pointers will contain all the entered devices. However, I get UB in this line:
**devices = device_buff;
Thanks so much 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++;
}
*devices = NULL;
printf("Display devices\n");
while(*devices != NULL) {
printf("Device [ %s ]\n", *devices++);
}
}
source
share