I want to use memset to set an array of length framenum. I know how to do it for 0
memset(arrayname, 0, framenum*sizeof(int));
,
but im not quite sure how to do it for -1. Any help would be greatly appreciated, thanks.
Last edited on
You don't use memset in C++, but rather std::fill or std::fill_n (defined in <algorithm>).
fill_n(arrayname, framenum, -1);
memset is unsuitable for that, because it sets each byte to a certain value, not each array element.
Last edited on