我有至多20长度的10个字符串数组,我建立如何将char [n] [length + 1]转换为C中的常量字符串数组?
char buffer[10][20] = {0};
//populate the buffer with 10 strings
//after this point, no more changes to the buffer allowed
//make a new pointer to indicate that I want the buffer finalized
const char **finalized = buffer;
但以前的失败,并警告
warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
做有一个字符串的工作
类似的东西char buffer[20] = {0};
//populate the buffer
const char *finalized = buffer;
在第一种情况下施放的正确方法是什么?
'{0}'是* *一个维阵列的初始值设定。 –
@ Eugene Sh .:没有。而且,这是荒谬的。在C语言中,'{0}'是一个惯用的通用零初始化器。它可以用来绝对*初始化*任何*。 – AnT
是的,但并非没有抱怨,例如'警告:初始化程序周围缺少大括号[-Wmissing-braces]'。 (作为'-Wall'的一部分启用) –