C++ program to read a line using getline() function.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string my_str;
cout << "Enter your name:";
getline (cin, my_str);
cout << "Your name is " << my_str;
return 0;
}
Output of program
Enter your name:SCS AU
Your name is SCS AU
No comments:
Post a Comment