This program should work just fine, I copied your code and I have no problem compiling or running this. Are you getting any errors or what is going wrong?
If the problem is just that it closes right after inputting a number, try adding:
At the bottom of the code, before 'return 0'.
This causes the program to wait for the user to tap the enter key before exiting.
Last edited on
I've just figured it out. The app was running so I oppened my "gerenciador de tarefas"(my pc is in portuguese) and ended the process. Now it's working. Thanks for the help anyway!