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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.