Initialize your counter back to -1 and the flipflop will be fixed.
I also use Bloodshed Dev C++ and had an issue with flipfloping for a project i have and its an issue that the value needs to go back to -1 and not 0.
I have been pretty much working with Bloodshed Dev C++ and while it has some bugs I havent found a suitable replacement to it. MS VC6 is one of my favorites, but I dont have a licensed copy of this. I ended up getting Borland along with a Book about 20 years ago and the only issues I had with Borland was that it wanted the the includes to be with .h and Microsoft VC6 had a fit with the .h's. The VC6 that I had when back in college was the student educational edition and it would compile and add a line to the program showing that it was compiled with that free student edition to keep people from using student edition to write programs compiled to be sold from the free student IDE. So before Bloodshed Dev C++ 5 I was using Borland a lot, but Borland had some library limitations.
I have tried Eclipse C++ as seen here, but had problems with it:
https://eclipse.org/cdt/Lastly if you ever pass a string to CIN buffer with Bloodshed Dev C++ 5 where each character of that string input is placed into an array, you can run into problems with the first character of the string being duplicate in the array so the work like HELLO
which should be array element 0 of "H" and array element 1 of "E" and array element 2 of "L" will be element 0 = H element 1 = H and element 2 = E. I fixed this by creating a write to array delay where counter in while loop starts at 0 and not until counter reaches 1 does it then allow the nested if condition to write the data from CIN buffer 1 character per iteration to the array. * This issue only happens in Bloodshed Dev C++ 5, Borland doesnt have this issue as well as the student edition trial edition of VC6.
Bloodshed Dev C++ isnt that bad if you know of work arounds to dodge the bugs. I dont find bugs often and write all sorts of programs using Bloodshed Dev C++ 5. But whenever I do something completely off the wall, outside of what I normally code there is always the question of... is Bloodshed Dev C++ 5 going to act up or not.
With the -1 reset vs the reset to 0 for flipflop counter in my one program I am onto version 3 of it now and have all sorts of flipping and flopping going on as well as a non fixed periodic switching between arrays. The most complex thing now is constructing the inverse of that because my program is taking information and scrambling it up like crypto with character substitution and any letter in the substitution doesnt always correspond to the same ascii character substitution. I coded up a draft to the inverse and ran into problems. And when i have a clear head and can tackle this full force without distraction I will charge ahead and solve the inverse scramble issue where something like Hello World scrambles to 7gE0<y3#(vX and the inverse decrypt program will be able to replace characters back to their original characters based on a number of keys like a combination lock such as 3 values that control the behavior of the flipflopping and the variable period of flip flopping among multiple arrays which are shuffled and SRAND seed value injection for each array so that the seeds themselves are the keys to the combination to get the data back to original form.