gcc 4.4.4 c89
warning assignment makes integer from pointer without a cast
**devices = device_buff;
warning: value computed is not used
*devices++;
我使用如下代码出现了上述警告。我的目标是从用户那里获取输入,并将该字符数组分配给指针数组。因此,我的指针数组将包含所有输入的设备。但是,在这行代码上我遇到了UB:
**devices = device_buff;
非常感谢您提供的任何建议。
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++);
}
}