EXPLORATION 4

image

Strings

In earlier Explorations, you used quoted character strings as part of each output operation. In this Exploration, you will begin to learn how to make your output a little fancier by doing more with strings. Start by reading Listing 4-1.

Listing 4-1.  Different Styles of String Output

#include <iostream> int main(){   std::cout << "Shape\tSides\n" << "-----\t-----\n";   std::cout << "Square\t" << 4 << '\n' <<                "Circle\t?\n";}

Predict the output from the program in Listing 4-1. You may already know what \t means. If so, this prediction is easy to make. If you don’t know, take a guess.

_____________________________________________________________ ...

Get Exploring C++ 11, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.