Arrayのサイズ非指定
sample.c
int main() {
int a[] = { 1, 2, 3 };
char c = 'x';
char *cptr = "xyz"; //equivalent to array[4] = {'x','y','z','\0'}
char carr1[] = {'a','b'};
char carr2[] = "text"; //equivalent to array[5] = {'t','e','x','t','\0'}
char *captr[] = {"p","q"};//equivalent to *array[2] = {*{'p','\0'}, *{'q','\0'}}
}
まとめ
記号 | 役割 | 区切り |
---|---|---|
{} | xxx(要素に準拠)[] | カンマ区切り |
"" | char[] | 文字区切り |
'' | char | - |