3 ms·
int hasz[200]; memset(hasz, 0, 200); yikes, that initializes the first 200 bytes to 0x00, or only the first 50 integers in the array. this code is... bad.
by nyanpasu64 6y ago
int hasz[200];
memset(hasz, 0, 200);
yikes, that initializes the first 200 bytes to 0x00, or only the first 50 integers in the array. this code is... bad.
- felixr 6y ago> only the first 50 integers or the first 100 integers https://gcc.gnu.org/wiki/avr-gcc https://gcc.gnu.org/wiki/avr-gcc
- MertsA 6y agoFor anyone who isn't well versed in C, int is most of the time 32 bits but it's architecture dependent with some machines being e.g. 16 bit. If you need the size to be exactly 32 bits then you can just use int32_t or similar and let the compiler make that happen regardless of the architecture it's compiling to. The original code should have specified 200 * sizeof(int) or better yet since it's a local variable just ditch the memset and change it to int hasz[200] = {}; which will do the same.