https://rentry.org/PPP2_p161 ⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34// Code derived from Stroustrup's PPP2 book // § 5.9.1 Practical debug advice // -and beginning on p 161 #include <iostream> using std::cin; using std::cout; // int f(int a) // { // if (a > 0) { /* do something */ // else // { /* do something else */ // } // } // oops! int main() { // note: try un-commenting all this code (one part at a time) and fixing it: // cout << "Hello, << name << '\n'; // oops! // cout << "Hello, " << name << '\n; // oops! // if (a<=0 // oops! // x = f(y); // int count; /* . . . */ ++Count; // oops! // char ch; /* . . . */ Cin>>c; // double oops! // x = sqrt(y)+2 // oops! // z = x+3; } build & run: g++ -std=c++20 -O2 -Wall -pedantic ./ch_05/main_p161.cpp && ./a.out sauce: Bjarne Stroustrup's PPP2 textbook /robowaifu/'s official C++ learning textbook thread Prev • Up • Next