Why does “memset(arr, -1, sizeof(arr)/sizeof(int))” not clear an integer array to -1?

前端 未结 6 1987
梦如初夏
梦如初夏 2020-11-27 12:25

Is it not possible to use memset on an array of integers? I tried the following memset call and didn\'t get the correct integer values in the

6条回答
  •  悲&欢浪女
    2020-11-27 13:14

    gcc provides a good array initialization shortcut

    int arr[32] = {[0 ... 10] = 3, [11 ... 31] = 4}

    mind the space before and after ...

提交回复
热议问题