Exercise: Paint the American Flag Onto Standard Output

Description

Write a program to print the American flag, like so:

$ ./american-flag
* * * * * * ==================================
 * * * * *  ==================================
* * * * * * ==================================
 * * * * *  ==================================
* * * * * * ==================================
 * * * * *  ==================================
* * * * * * ==================================
 * * * * *  ==================================
* * * * * * ==================================
==============================================
==============================================
==============================================
==============================================
==============================================
==============================================

The program does not simply output those lines as-is, like

NO!
std::cout << "* * * * * * ==================================" << std::endl;

Rather, it defines a function to compose the output:

void print_chars(char c, const std::string& sep, unsigned int n);

To print the line above, for example, the program would use that function like so:

print_chars('*', " ", 6);
cout << ' ';
print_chars('=', "", 34);

Dependencies

cluster_cxx03 C++ cluster_cxx03_exercises_misc Exercises: Miscellaneous cxx03_exercises_misc_american_flag Exercise: Paint the American Flag Onto Standard Output