It also exits for me but how many times can you type any number besides 5? Because If I do it more than 7 times then it suddenly goes into an infinite loop and I have to Ctrl + C to shut it down. Thats what I don't understand.
Thats exactly whats strange, there is no error. The program runs fine but if I don't type 5 in 7 tries then it suddenly does an infinite loop displaying "Please enter anything but 5: " with my last entered number at the end.
Try editing this line cout << num << '\n'; so it is like this cout << num << endl;, or if you don't want a new line like this cout << num << flush;
Basically what that code does is endl creates a newline and flushes the buffer, and flush just flushes the buffer and that is it.
That might correct your error, let me know if it didn't and I will try and help find out what is wrong to the best of my ability.
EDIT: Also just to make sure you are not entering anything that is not a integer are you? Like "hello", or 'a', or 1.05 these are all not integers and will cause a infinite loop because your stream is in a error state.
I am currently using codeblocks but is there any other good compilers you can recommend that are free or not? Using the cout << num << endl; or
cout << num << flush; didn't help but is it possible it might have anything to do with installion location?
To answer your question to where I don't make sense, I only get the permission denied error when I use debug build target but when I switch
it to release the error goes away which is strange, sorry if I confused you.
Could the permission error be because I am using windows 7?
Which version of code blocks/MinGW did you install? Release 08.02 is only supported for windows vista / xp / 2000. Either way, I might try re-installing the newest version from here: http://www.codeblocks.org/downloads/26
Maybe your program was not shut down correctly after you compiled it before when your code was fully complete, and it's still open on your machine from the original. Try opening task manager, and going to your processes tab and terminating any process that resembles this program you made, and re compile and run again, also delete the executable file first.