https://rentry.org/PPP2_p122a

// Code derived from Stroustrup's PPP2 book
// § 4.6.3 A numeric example
//  -and beginning on p 122

#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::vector;

int main()
{
  cout << "Please enter temperatures: ";
  vector<double> temps;  // temperatures
  double         temp;

  while (cin >> temp)       // read
    temps.push_back(temp);  // put into vector

  // … temp might be used here …
}

build & run:

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

PrevUpNext

Edit
Pub: 08 Feb 2023 01:56 UTC
Edit: 29 Apr 2023 08:42 UTC
Views: 442