How to Take Multiple Line String Input in C++? Last Updated : 01 Feb, 2024 Comments Improve Suggest changes Like Article Like Report In C++, taking string input is a common practice but the cin is only able to read the input text till whitespace. In this article, we will discuss how to read the multiple line of text input in C++. For Example, Input:Enter Your Text: This is amultiline text.Output:You Have Entered:This is amultiline text.Reading Multiple Line String Input in C++ To read multiple lines of text input in C++, we can use the getline() function with a loop and a condition that states when you want to stop taking the input. While looping keep storing each line in a vector of string that can be used for processing later on. C++ Program to Read Multiple Lines of InputThe below example shows how to read muti-line string input in C++. C++ // C++ Program to Read Multiple Lines of Input #include <iostream> #include <string> #include <vector> using namespace std; int main() { // Declare variables string str; vector<string> s; // Prompt user to enter multiple lines of text cout << "Enter multiple lines of text: " << endl; // Read input lines until an empty line is encountered while (getline(cin, str)) { if (str.empty()) { break; } s.push_back(str); } // Display the entered lines cout << "You entered the following lines: " << endl; for (string& it : s) { cout << it << endl; } return 0; } Output Enter multiple lines of text: Hello! GeekWelcome to GeeksforGeeks Learn to codeYou entered the following lines: Hello! GeekWelcome to GeeksforGeeksLearn to code Comment More infoAdvertise with us Next Article How to Take Multiple Line String Input in C++? S surya9c5sb Follow Improve Article Tags : C++ Programs C++ cpp-input-output cpp-string CPP Examples +1 More Practice Tags : CPP Similar Reads How to Take Multiple String Inputs in a Single Line in C++? In C++, strings are used to store textual data. While working with user input, we often may need to take multiple string inputs in a single line only. In this article, we will learn how to take multiple string inputs in a single line. Example Input: Hi,Geek,Welcome,to,GfG delimiter = ',' Output: Str 2 min read How to Take Long String Input With Spaces in C++? In C++, we often take long strings with a lot of characters as inputs with spaces but if we use cin then our input gets terminated as soon as whitespace is encountered. In this article, we will discuss how to take long strings with spaces as input in C++. Take Long String Input With Spaces in C++To 2 min read How to Take Multiple Input from User in C++? In C++, we use cin when we want to take input from the user. We often also need to take more than one input at a time. In this article, we will learn how to take multiple inputs in C++. Take Multiple Inputs from a User in C++To take multiple inputs from users, we can repeatedly use the std::cin usin 2 min read How to Read Multiple Numbers from a Single Line of Input in C++? In C++, when working with user inputs we often need to take input of multiple numbers from a user in a single line. In this article, we will learn how to read multiple numbers from a single line of input in C++. Example Input: 1 7 0 4 6 8 Output: Entered Number: 1, 7, 0, 4, 6, 8Take Multiple Numbers 2 min read How to Handle Multiple String Inputs with Spaces in C++? In C++, strings are a sequence of characters that might contain spaces in many cases but we can read only the input text till whitespace using cin. In this article, we will learn how to handle multiple string inputs with spaces in C++. Example: Input:Enter multiple strings:String1String2Output:You E 2 min read How to Read a Line of Input Text in C++? In C++, we often need to take input from the user by reading an input text line by line but the cin method only takes input till whilespace. In this article, we will look at how to read a full line of input in C++. For Example, Input: This is a text.Output: Entered Text: This is a text.Taking a Line 2 min read How to Concatenate Multiple Strings in C++? In C++, to concatenate multiple strings means we need to combine two or more strings into a single string. In this article, we will learn how to concatenate multiple strings in C++. Example Input: str1="Hello!" str2="Geek," str3="Happy Coding." Output: Hello! Geek, Happy Coding.Concatenate Multiple 2 min read How to input a comma separated string in C++? Given an input string which is comma-separated instead of space, the task is to parse this input string in C++.First, let us understand what difference does it create if the input string is comma-separated. Taking input a whitespace-separated stringTaking input a whitespace-separated string in C++ i 2 min read How to Replace Text in a String Using Regex in C++? Regular expressions or what we can call regex for short are sequences of symbols and characters that create a search pattern and help us to find specific patterns within a given text. In this article, we will learn how to replace text in a string using regex in C++. Example Input: str = "Hello, Worl 2 min read Take String as Input in C++ Strings are used to store the textual information. Taking a string as input is a very common operation used in almost all fields of programming. In this article, we will look at different ways to take string as input.The simplest way to take string as the user input is to use cin object. Let's take 2 min read Like