Thursday, March 2, 2017

Getline Command in C++

Hi there in this article I would like to share with you how to use getline command in C++. This program is very simple and easy to understand it will ask the users name and address and display the input data in the screen.

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

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

#include <iostream>

using namespace std;

int main()

{
    string name, address;

    cout << "\n\n";
    cout << "Enter you name : ";
    getline(cin,name);

    cout << "Enter your home address: ";
    getline(cin,address);
    cout << "\n\n";
    cout << "Hi " << name;
    cout << "\n\n";
    cout <<"You present home address is " <<address;
    cout << "\n\n";
    cout << "\tEnd of Program";
    cout << "\n\n";
}


No comments:

Post a Comment