What is the purpose of the unary plus (+) operator in C?

前端 未结 8 2103
攒了一身酷
攒了一身酷 2020-11-28 05:58

In C, it\'s legal to write something like:

int foo = +4;

However, as far as I can tell, the unary plus (+) in +4

8条回答
  •  旧时难觅i
    2020-11-28 06:43

    Pretty much. It's mainly present for completeness, and to make constructions like this look a little cleaner:

    int arr[] = {
        +4,
        -1,
        +1,
        -4,
    };
    

提交回复
热议问题