は私がCで文字列の定数配列にchar [n] [length + 1]をキャストする方法はありますか?
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;
を構築していますほとんどの20の長さの10個の文字列の配列を持っていますが、以前は警告
warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
つの文字列と類似した何かをすることに失敗した
作品char buffer[20] = {0};
//populate the buffer
const char *finalized = buffer;
最初のケースでキャストする正しい方法は何ですか?
は '{0}' *の1 *次元配列の初期化です。 –
@Eugene Sh .:いいえさらに、それは不合理です。 C言語では '{0}'は慣用的な汎用ゼロ初期化子です。これは絶対に何かを0に初期化するのに使うことができます。 – AnT
はい、申し訳ありません。 '警告:イニシャライザ[-Wmissing-braces]の周囲にカッコがありません。 ( '-Wall'の一部として有効になります) –