有人可以解释一下这是做什么的以及它如何是合法的 C 代码吗?我在这段代码中找到了这一行:http://code.google.com/p/compression-code/downloads/list http://code.google.com/p/compression-code/downloads/list,这是 Vitter 算法的 C 实现自适应霍夫曼编码 http://en.wikipedia.org/wiki/Adaptive_Huffman_coding
ArcChar = ArcBit = 0;
从函数来看:
void arc_put1 (unsigned bit)
{
ArcChar <<= 1;
if( bit )
ArcChar |= 1;
if( ++ArcBit < 8 )
return;
putc (ArcChar, Out);
ArcChar = ArcBit = 0;
}
ArcChar 是一个int
ArcBit 是一个unsigned char
表达式的值(a = b)
的值是b
,所以你可以用这种方式链接它们。它们也是右结合的,所以一切顺利。
本质上
ArcChar = ArcBit = 0;
is (approximately1) the same as
ArcBit = 0;
ArcChar = 0;
由于第一个赋值的值是被赋值的值,因此0
.
就类型而言,尽管ArcBit
is an unsigned char
分配的结果将扩大到int
.
1 It's not exactly the same, though, as R.. points out in a comment below.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)