GetLine and Ignore
Submissions: 8921   Accuracy:


  Difficulty: Easy   Marks: 2
Associated Course(s):   Fork CPP

There are many times when when need to take input of a string that contains multiple words.
Here, we will learn how to take input of a string that comprises of multiple words. Also, we will learn to clear the input buffer. Your task is to take input of strings and integers and produce the output.

Note : Use std:cin, getline(), cin.ignore().
Note 2: When cin is followed by getline, it creates a problem that can be circumvented by using cin.ignore. You can read more about it here

Input Format:
First line of input contains T,  number of testcases. For each testcase, there will be three lines of input. First line contains string, second line contains integer, and third line again contains string.

Output Format:
For each testcase, print the variables in same order as taken in input.

User Task:
Your task is to complete the function getLineAndIgnore() to take input of strings and learn how and when to use cin.ignore().

hello world

hello world

** For More Input/Output Examples Use 'Expected Output' option **

Author: Dhiman Mayank

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.