Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 为什么';没有类型转换的t复合文字赋值工作_C_C99_Compound Literals - Fatal编程技术网

C 为什么';没有类型转换的t复合文字赋值工作

C 为什么';没有类型转换的t复合文字赋值工作,c,c99,compound-literals,C,C99,Compound Literals,我对C语言中的文字有一个问题 int a; //a is an integer that is assigned an integer literal 414 a = 414; float b; //b is a float that is assigned a float literal of 3.14 b = 3.14; struct point { int x,y; }; struct point b; //{5,6} is a compound literal that i

我对C语言中的文字有一个问题

int a;
//a is an integer that is assigned an integer literal 414
a = 414;

float b;
//b is a float that is assigned a float literal of 3.14
b = 3.14;

struct point {
    int x,y;
};

struct point b;
//{5,6} is a compound literal that is assigned to a struture.
b = {5,6}; //doesn't work.

b = (struct point){5,6}; //works.
没有排字就不行了?原因是什么?

(结构点){5,6}
作为一个整体是一个复合文字

C11§6.5.2.5复合文字 一种后缀表达式,由括号中的类型名和括号中的括号组成 初始值设定项列表是一个复合文本


既然在初始化之前可以从点b的偏差推断出类型,为什么它不起作用?@liv2hak
(struct point)
不是强制转换,它是复合文字的一部分。不能从符号表推断出来吗?@liv2hak:无法推断
{5,6}
可以是
int[2]
,也可以是
结构{char a,b;}
。。。