I am trying to initialize a 2d array with some integer.If I initialize the array to 0 I am getting correct results but If I use some other integer I get some random values.<
memset works on a byte-by-byte basis only. Zeroing out the bits works in general because all integral zeros are generally all-zero-bits, so that grouping four all-zero-bit bytes into one all-zero-bits int still gives you zero. For things that are not bytes, though, the simplest way to initialize all of them is just to explicitly initialize all of them.