https://rentry.org/PPP2_p68a

// Code derived from Stroustrup's PPP2 book
// § 3.4 Operations and operators
// -beginning on p 68

#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::string;

// read first and second name
int main()
{
  cout << "Please enter your first and second names\n";
  string first;
  string second;
  cin >> first >> second;              // read two strings
  string name = first + ' ' + second;  // concatenate strings
  cout << "Hello, " << name << '\n';
}

build & run:

g++ -std=c++20 -O2 -Wall -pedantic ./ch_03/main_p68a.cpp && ./a.out

PrevUpNext

Edit
Pub: 17 Jan 2023 06:43 UTC
Edit: 29 Apr 2023 06:13 UTC
Views: 663