memset
sets the number of bytes you specify to the value you have given. So it is working - you have allocated a chunk of memory that is
nSize
bytes long, then set all of them to the value zero.
The problem is with your loop, which frankly is a load of rubbish (but you know that, because it won't compile, will it?)
Try this:
for (i = 0; i < N; i++)
{
printf("%d ", *(a + i));
}
Bear in mind that
a
is an
int
pointer - not a byte. So when you add a value to it, you are incrementing by the size of an integer already.