Initializing entire array with memset

前端 未结 4 1153
天涯浪人
天涯浪人 2021-01-19 13:09

I have initialised the entire array with value 1 but the output is showing some garbage value. But this program works correctly if i use 0 or -1 in place of 1. So are there

4条回答
  •  春和景丽
    2021-01-19 13:49

    memset is an operation that sets bits.

    If you want to set a value use a for-loop.

    Consider a 4-bit-integer:

    Its value is 1 when the bits are 0001 but memset sets it to 1111

提交回复
热议问题