Is this program having any sequence point issues?

前端 未结 3 365
自闭症患者
自闭症患者 2021-01-07 14:21
#include
 int main()
 {  
       int i=7,j;
       j=(i++,++i,j*i); 
       return 0;
}

j=(i++,++i,j*i);Is this well defined ? Let m

3条回答
  •  孤街浪徒
    2021-01-07 14:48

    In your code " ," will be work as sequence point.

    so in this

    j=(i++,++i,j*i);
    

    expression would be work from left to right.
    so at first i++ then ++i and then j*i

    at the last j*i would be stored in j;

    but lastly your result would be elegant because " j " have no predefined data
    so undefined value would be stored in j.

    if you don't use " () "

    your code would be work as single statement such as

    j=i++;
    ++i;
    j*i;
    

提交回复
热议问题