The functionality of the enter key is implemented by the shell program, and the C++ standard library does not define any control over it. You need to send some interprocess signal to get the shell, or whatever is outputting to cin
(on Unix, identified by file descriptor 1), to flush its output.
The usual way to provide an interactive text interface on a Posix system is ncurses, but I haven't seen it used with iostreams. (Well, I'm not really familiar with curses at all.)