I do not yet understand how vim and emacs text editors are involved here, though you can and do reference those repeatedly.
With a default install on macOS, AFAIK the text editors are not involved in C++ processing cin for input, or getline().
Because unless you're using those editors as an IDE and are trying to build and run (and the results failing to prompt, as you keep repeating) within the context of those text editors—with an add-on plug-in or other such customization or makeprg or such—those editors are not involved here.
And if the add-on plug-in or customization you are using here is not working, well, at the risk of demonstrating my hammerlock grasp of the obvious, stop using it and build using the classic command-line pattern, and contact the folks maintaining the vim or emacs plug-in for assistance.
Here's an example of what I'd expect to happen:
https://stackoverflow.com/questions/21474662/compiling-and-running-a-c-program-with-vim#21477312
If you're doing something different than this, please be more specific.
I use vim a whole lot, quite possibly with some old-fashioned habits, and this isn't a sequence or situation I've encountered. But as an IDE, Xcode... Which runs circles around older methods.