Actually i want the user to enter a line of string having multiple words in it for example "My name is ABC". What is the C/C++ code for this purpose?
Thanks in advance
#include<iostream>
#include<string>
using namespace std;
int main(){
string testString;
getline(cin, testString);
{
if you have
cin >> otherVariables
You need to delete the newline buffer in between by adding:
cin.ignore()
You should have something like:
string userMessage;
cin.ignore();
getline(cin, testString);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With