Is there a way to partially reset to zero an integer array. I currently use a for loop
1 2
for(short i=5; i<arraySize ; i++)
myArray[i]=0;
I found reference for using memset() , however it seems to only work if you want to reset the entire array. not partially.
Any suggestions that would be faster than using a for loop
memset() can be used to set any amount of memory, but it will set bytes, not elements. So, if you want to set all elements in an array to, say, 25, it will probably not work (it depends on the size of the elements and your CPU architecture). Setting to zero works in all sensible cases.
std::fill() can set elements, but it's no faster than a for loop.