I need to set all values of an array equal to one. I have been trying to do this using the following code:
int bulbSwitch(int n) {
int bulbs[n];
memset(bulbs, 1, n * sizeof(int));
...
However, the debugger shows that all values within the array are actually being set to 16843009. Without memset
, the array values are seemingly random, positive integers. Why is this, and how would I fix it?