But state should be 1 as default.
Why? Nothing in the code makes it so.
You should also initialize "state" to 1, not 0. 0 is an invalid value per your logic.
But state should be 1 as default.
Why? Nothing in the code makes it so.
You should also initialize "state" to 1, not 0. 0 is an invalid value per your logic.