This C++ Program which prints the name of the user using streams. The program asks user to input his/her name using Input Streams, the name is saved in a string variable and is printed using Output Stream.
Here is source code of the C++ program which prints the name of the user using streams. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C++ Program to Print the Name of the User using Output Stream
*/
#include
#include
int main()
{
std::string firstname;
std::cout << "Hello User, Enter your first name.\n ";
std::cin >> firstname;
std::cout << "Hello " << firstname
<<". It was nice to know your name!\n";
}
$ g++ main.cpp
$ ./a.out
Hello User, Enter your first name.
George
Hello George. It was nice to know your name!