If I compile code which uses cin using the command prompt, then run the compiled program a new window opens when it reaches the cin line of code, for the input. If there is no cin used then all printing happens in the original window. Is there a way to stop this behavior of the opening of a new window?
I'm pretty sure that before networking was started, people used sockets to make programs interact with other programs, and that is what I believe what you are trying to do, and I am pretty sure that there is no other way of doing it.
So either create a simple gui, or learn networking. You could try ncurces if you desperately need the terminal look, but it will be more harder than making a simple gui.