#include "pch.h" #include <iostream> #include <Windows.h> #include <string> using namespace std; int main(int argc, const char * argv[]) { setlocale(LC_CTYPE, "rus"); string ew_1, rw_1; getline(cin, ew_1); cout << " - "; getline(cin, rw_1); return 0; } 

Hello! I have such a problem. I need to be able to write (English words) - (dash) (Russian word) on the same line. All this should be on one line! But after entering the first word, it moves me to the next line. How to make it so that everything was on one. Thank you in advance!

    1 answer 1

    You can use the first variant of the getline function with the delimiter character. But the symbol '-' will have to enter hands. For example:

     cout << "Input: "; getline(cin, ew_1, '-'); getline(cin, rw_1, '\n'); cout << "Output: " << ew_1 << " - " << rw_1; 

    Then in the console:

     Input: hello-привет Output: hello - привет 

    It can also be useful: How do I input variables using cin without creating a new line?