c++ascii-art

ASCII art in C++


I'm attempting to put in ASCII art in a C++ program and did so by manually printing each line, but the outcome was nothing like the ASCII art. It's like:

Enter image description here

Does this occur because the characters are not recognizable by the prompt or have I not done it correctly?

Here is the ASCII art I'm trying to do:

_____/\\\\\\\\\________/\\\\\\\\\\\__________/\\\\\\\\\__/\\\\\\\\\\\__/\\\\\\\\\\\_        
 ___/\\\\\\\\\\\\\____/\\\/////////\\\_____/\\\////////__\/////\\\///__\/////\\\///__       
  __/\\\/////////\\\__\//\\\______\///____/\\\/_______________\/\\\_________\/\\\_____      
   _\/\\\_______\/\\\___\////\\\__________/\\\_________________\/\\\_________\/\\\_____     
    _\/\\\\\\\\\\\\\\\______\////\\\______\/\\\_________________\/\\\_________\/\\\_____    
     _\/\\\/////////\\\_________\////\\\___\//\\\________________\/\\\_________\/\\\_____   
      _\/\\\_______\/\\\__/\\\______\//\\\___\///\\\______________\/\\\_________\/\\\_____  
       _\/\\\_______\/\\\_\///\\\\\\\\\\\/______\////\\\\\\\\\__/\\\\\\\\\\\__/\\\\\\\\\\\_ 
        _\///________\///____\///////////___________\/////////__\///////////__\///////////__

Code:

cout << "_____/\\\\\\\\\________/\\\\\\\\\\\__________/\\\\\\\\\__/\\\\\\\\\\\__/\\\\\\\\\\\_        \n";
cout << " ___/\\\\\\\\\\\\\____/\\\/////////\\\_____/\\\////////__\/////\\\///__\/////\\\///__       \n";
cout << "  __/\\\/////////\\\__\//\\\______\///____/\\\/_______________\/\\\_________\/\\\_____      \n";
cout << "  _\/\\\_______\/\\\___\////\\\__________/\\\_________________\/\\\_________\/\\\_____     \n";
cout << "    _\/\\\\\\\\\\\\\\\______\////\\\______\/\\\_________________\/\\\_________\/\\\_____    \n";
cout << "    _\/\\\/////////\\\_________\////\\\___\//\\\________________\/\\\_________\/\\\_____   \n";
cout << "      _\/\\\_______\/\\\__/\\\______\//\\\___\///\\\______________\/\\\_________\/\\\_____  \n";
cout << "       _\///________\///____\///////////___________\/////////__\///////////__\///////////__\n";

Solution

  • The escape sequences are interpreted as single special or other characters, hence the strange output. "\\" means '\' for example.

    You can use a raw string literal:

    #include <iostream>
    
    int main()
    {
        std::cout << R"(
    _____/\\\\\\\\\________/\\\\\\\\\\\__________/\\\\\\\\\__/\\\\\\\\\\\__/\\\\\\\\\\\_        
     ___/\\\\\\\\\\\\\____/\\\/////////\\\_____/\\\////////__\/////\\\///__\/////\\\///__       
      __/\\\/////////\\\__\//\\\______\///____/\\\/_______________\/\\\_________\/\\\_____      
       _\/\\\_______\/\\\___\////\\\__________/\\\_________________\/\\\_________\/\\\_____     
        _\/\\\\\\\\\\\\\\\______\////\\\______\/\\\_________________\/\\\_________\/\\\_____    
         _\/\\\/////////\\\_________\////\\\___\//\\\________________\/\\\_________\/\\\_____   
          _\/\\\_______\/\\\__/\\\______\//\\\___\///\\\______________\/\\\_________\/\\\_____  
           _\/\\\_______\/\\\_\///\\\\\\\\\\\/______\////\\\\\\\\\__/\\\\\\\\\\\__/\\\\\\\\\\\_ 
            _\///________\///____\///////////___________\/////////__\///////////__\///////////__        
    )" << '\n';
    
        return 0;
    }
    

    live demo