C: transitive (double) assignments

后端 未结 6 1166
半阙折子戏
半阙折子戏 2021-01-20 07:11

I have used such construct in C:

list->head = list->tail = NULL;

and now I consider whether this really mean what I suppose.

<
6条回答
  •  南笙
    南笙 (楼主)
    2021-01-20 07:41

    The assignment operator is right to left associative.

    Thus this expression statement

    list->head = list->tail = NULL;
    

    is equivalent to

    list->tail = NULL;
    list->head = list->tail;
    

提交回复
热议问题