G
Guido Franzke
Guest
Hello,
I have an integer array and want to fill it with a number different of 0.
The for-loop is slow, so I want to use memset.
int a[1000];
for (int i=0; i<1000; i++) a = 0;
memset(a,0,1000*sizeof(int)); // this is ok
for (int i=0; i<1000; i++) a = 5;
memset(a,5,1000*sizeof(int)); // not ok
When setting the array to 0, memset works. But I want to set it to a number (e.g. 5). If I use the second memset, the values are not 5 but a very big value.
What am I doing wrong?
Regards, Guido
Continue reading...
I have an integer array and want to fill it with a number different of 0.
The for-loop is slow, so I want to use memset.
int a[1000];
for (int i=0; i<1000; i++) a = 0;
memset(a,0,1000*sizeof(int)); // this is ok
for (int i=0; i<1000; i++) a = 5;
memset(a,5,1000*sizeof(int)); // not ok
When setting the array to 0, memset works. But I want to set it to a number (e.g. 5). If I use the second memset, the values are not 5 but a very big value.
What am I doing wrong?
Regards, Guido
Continue reading...