Now i remember i wanted to answer to this question too.
What do you mean by
I can not debug again because I have to close the cmd
Do you want to restart the program within the debugger?
To achieve this there are multiple ways:
1) Write your program in a way you can easily restart it by setting a variable (for example use state machines with the first state reseting all variable to a default value). Now you can simply change this variable in the watches window.
2) If you are on linux you can use the checkpoint feature of gdb:
https://sourceware.org/gdb/onlinedocs/gdb/Checkpoint_002fRestart.html this is not supported by codeblocks yet, so you have to type the commands by hand in the gdb input field at the bottom. I have planed to add this for a long time, but there are other things to fix for gdb first...
3) Jump back to the beginning of main. This can be dangerous, because variables are not initialized like at the startup of your program. This is also not supported by codeblocks directly but you can type "jump main()" in the gdb command line at the bottom...
NOTE: this method has many pitfalls:
* Memory leaks
* does not work on multi threaded apps
* Open files remain open
* ecc....
sorry for the late reply, i hope this helped...