initializing an array of ints

前端 未结 7 866
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 05:00

Does anyone have a way to initialize an array of ints (any multi-byte type is fine really), to a non-zero and non -1 value simply? By which I mean, is there a w

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 05:56

    You said something about 2 lines but you can do it in one line using comma ,operator.

    for(count = 0; count < 30 ; arr[count] = 1,count++);
    

提交回复
热议问题