How can I make a script that opens terminal and runs my executable?
When you double-click a .command file, Terminal.app will open, and execute /path/to/file.command ; exit; which means it will execute the content of the file.command script, and THEN exit.

If your Terminal is exiting before your executable can receive input, that seems to indicate that either your .command is not calling your executable correctly, or your executable somehow doesn't wait to receive input before exiting.

To be able to help you further, you'd need to provide an example .c/.cpp file to compile, and the content of your .command file.

I myself tried with a .command file that contains only:

$HOME/Downloads/go.sh


And I was able to ask for input in go.sh (using read -p) before the Terminal exited.