Skip to content

Text Art

Since we can’t draw images in the terminal, we can use text art to create ASCII art. Text art is a form of drawing that uses characters to create images. In C++, we can create text art by printing characters in a specific pattern.

Here are the two sites I recommend for generating text art:

Let’s say for example, with the Picsart’s Text Art Generator, We convert the word “NEUST” to text art with the “Standard text art” style, we would get the following:

Terminal window
_ _ _____ _ _ ____ _____
| \ | | ____| | | / ___|_ _|
| \| | _| | | | \___ \ | |
| |\ | |___| |_| |___) || |
|_| \_|_____|\___/|____/ |_|

If we want to print this text art in C++, we will need to fix some of the characters, specifically the backslashes. Since backslashes are escape characters in C++, we need to escape them by adding another backslash before them. Here is the corrected text art:

So the corrected text art would look like this:

Terminal window
_ _ _____ _ _ ____ _____
| \\ | | ____| | | / ___|_ _|
| \\| | _| | | | \\___ \\ | |
| |\\ | |___| |_| |___) || |
|_| \\_|_____|\\___/|____/ |_|

Then we will need to print this text art in C++ using the cout object. Here is an example of how to print the text art in C++:

main.cpp
#include <iostream>
using namespace std;
int main() {
cout << " _ _ _____ _ _ ____ _____" << endl
<< "| \\ | | ____| | | / ___|_ _|" << endl
<< "| \\| | _| | | | \\___ \\ | |" << endl
<< "| |\\ | |___| |_| |___) || |" << endl
<< "|_| \\_|_____|\\___/|____/ |_|" << endl;
return 0;
}

The output of the program will be:

Terminal window
_ _ _____ _ _ ____ _____
| \ | | ____| | | / ___|_ _|
| \| | _| | | | \___ \ | |
| |\ | |___| |_| |___) || |
|_| \_|_____|\___/|____/ |_|