Sunday, February 19, 2017

Getline in C++

In this article I would like to share with you a sample program that I wrote that shows you how to use getline command in C++ to get input value from our user.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <string>

using namespace std;

 main() {

  string address,name;

  cout << "Name ";
  cin >> name;
  cout << "Enter your complete address : ";
   cin.ignore(80,'\n');
   getline(cin, address);

 cout << "\n\n";
 cout << "Hello " << name;
 cout << "\n";
 cout << "You address is ";
 cout << address;
   cout << "\n\n";
   system("PAUSE");
 }

No comments:

Post a Comment