-1

when I use " cin >> string " if I input one or several new lines without putting any characters the program doesn't finish the cin command until I input a character or a string

normally when i put only a new line the console go to the beginning of the new line.

how do I insert from input into the string "null " or "\n" and finally continue the program?

  • 1
    Use [std::getline](https://en.cppreference.com/w/cpp/string/basic_string/getline) to read a line `cin >> string` reads up to the first white space character typed. Should be something like `std::string line; std::getline(std::cin, line;` however be aware of this: [https://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction](https://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction) – drescherjm Apr 06 '23 at 17:04

1 Answers1

0

use getline() function to read more then one line.

Syntax

getline(cin,variable_name);
vatsal mangukiya
  • 261
  • 2
  • 14