https://rentry.org/PPP2_p65

// Code derived from Stroustrup's PPP2 book
// § 3.3 Input and type
// -beginning on p 65

#include <iostream>
#include <string>

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

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

build & run:

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

PrevUpNext

Edit
Pub: 17 Jan 2023 04:47 UTC
Edit: 29 Apr 2023 06:09 UTC
Views: 641