Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Command Line Arguments and C++ ASCII FONT ART I am NOT ASKING for the solution--I would like to get advice, tips, suggestions, and hints to

Command Line Arguments and C++ ASCII FONT ART

I am NOT ASKING for the solution--I would like to get advice, tips, suggestions, and hints to help me write my own source code. Thank you.

Arg1: String "display"

Arg 2: Filename containing the bitmap font. The bitmap font file will render each character in large format.

Arg3: The message - a string of one or more characters such as "H" or "Hello World!"

Arg4: The character that is to be used as the foreground (the letters)

Arg5: The character that will be used as the background for the ASCII font art.

Command Line Terminal:

./ ascii_font_art.out display simple_font.txt Hello\ World! @ .

The ' period character "." is argument 5.

ASCII font art message will appear on the terminal (std:: cout)

Or use Command LIne file-redirection to send std::cout to a file.

#include #include #include #include #include #include #include #include // ====================================================================================== // Helper function to read the provided font from a file. The format // of the font file is described in comments below. The width, // height, and bitmap_letters variables are set by this function. void ReadFont(const std::string &font_file, int &width, int &height, std::vector > &bitmap_letters) { // open the font file for reading std::ifstream istr(font_file.c_str()); if (!istr) { std::cerr << "ERROR: cannot open font file " << font_file << std::endl; exit(0); } // read in the width & height for every character in the file istr >> width >> height; assert (width >= 1); assert (height >= 1); // Create a vector to store all 256 ASCII characters of the // characters. Each character is represented as a vector of // strings that are each wide. Initially the // characters are unknown (represented with the '?' character). bitmap_letters = std::vector > ( 256, std::vector ( height, std::string(width, '?'))); // read in all the characters // first is the ascii integer representation of the character int ascii; while (istr >> ascii) { assert (ascii >= 0 && ascii < 256); // next the character is printed in single quotes char c; istr >> c; assert (c == '\''); // use std::noskipws to make sure we can read the space character correctly istr >> std::noskipws >> c; // verify that the ascii code matches the character assert (c == (char)ascii); // switch back to std::skipws mode istr >> std::skipws >> c; assert (c == '\''); // read in the letter std::vector bitmap; std::string tmp; for (int i = 0; i < height; i++) { istr >> tmp; assert ((int)tmp.size() == width); // make sure the letter uses only '#' and '.' characters for (unsigned int j = 0; j < tmp.size(); j++) { assert (tmp[j] == '.' || tmp[j] == '#'); } bitmap.push_back(tmp); } // overwrite the initially unknown letter in the vector bitmap_letters[ascii] = bitmap; } } // ====================================================================================== 

In this file every letter uses # for the foreground character and . for the background. Youll need to swap in the desired foreground & background characters as you output the artwork. We have provided code to help your program load the font file. Please review this code carefully. You may use/modify this code as you wish in your solution.

I am NOT ASKING for the solution--I would like to get advice, tips, suggestions, and hints to help me write my own source code. Thank you.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

What are the arguments for and against a national accounting plan?

Answered: 1 week ago

Question

Question Can plan participants borrow from a VEBA?

Answered: 1 week ago