Thread: How to use ASCII Art in C/C++

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    3

    Question How to use ASCII Art in C/C++

    How do I print this without generating errors?
    Code:
        printf(" ||====================================================================|| \n");
        printf(" ||//$\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//$\\|| \n");
        printf(" ||(100)==================| RESERVE BANK OF INDIA|================(100)|| \n");
        printf(" ||\\$//        ~         '------========--------'                \\$//|| \n");
        printf(" ||<< /        /$\              // ____ \\                         \ >>|| \n");
        printf(" ||>>|        //L\\            // ///..) \\              XXXX       |<<|| \n");
        printf(" ||<<|        \\ //           || <||  >\  ||                        |>>|| \n");
        printf(" ||>>|         \$/            ||  $$ --/  ||          XXXXXXXXX     |<<|| \n");
        printf(" ||<<|     Free to Use        *\\  |\_/  //*                        |>>|| \n");
        printf(" ||>>|                         *\\/___\_//*                         |<<|| \n");
        printf(" ||<<\      Rating: E     _____/ M GANDHI \________    XX XXXXX     />>|| \n");
        printf(" ||//$\                 ~|    REPUBLIC OF INDIA   |~               /$\\|| \n");
        printf(" ||(100)===================   ONE HUNDRED RUPEES =================(100)|| \n");
        printf(" ||\\$//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\$//|| \n");
        printf(" ||====================================================================|| \n");
    Last edited by rohitdwivedula; 02-26-2014 at 08:16 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,719
    Escape the backslashes.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    4,509
    The suggestion by laserlight is correct - however, this will make the "image" as seen in your editor uneven and difficult to take in visually.

    Another option would be to create the ASCII art in a text file, thereby preserving the "image" source visually, and simply read/print this text file.

    For example:

    main.c
    Code:
    #include <stdio.h>
    #define MAX_LEN 128
    
    void print_image(FILE *fptr);
    
    int main(void)
    {
        char *filename = "image.txt";
        FILE *fptr = NULL;
    
        if((fptr = fopen(filename,"r")) == NULL)
        {
            fprintf(stderr,"error opening %s\n",filename);
            return 1;
        }
    
        print_image(fptr);
    
        fclose(fptr);
    
        return 0;
    }
    
    void print_image(FILE *fptr)
    {
        char read_string[MAX_LEN];
    
        while(fgets(read_string,sizeof(read_string),fptr) != NULL)
            printf("%s",read_string);
    }
    image.txt
    Code:
    ||====================================================================||
    ||//$\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//$\\||
    ||(100)==================| RESERVE BANK OF INDIA|================(100)||
    ||\\$//        ~         '------========--------'                \\$//||
    ||<< /        /$\              // ____ \\                         \ >>||
    ||>>|        //L\\            // ///..) \\              XXXX       |<<||
    ||<<|        \\ //           || <||  >\  ||                        |>>||
    ||>>|         \$/            ||  $$ --/  ||          XXXXXXXXX     |<<||
    ||<<|     Free to Use        *\\  |\_/  //*                        |>>||
    ||>>|                         *\\/___\_//*                         |<<||
    ||<<\      Rating: E     _____/ M GANDHI \________    XX XXXXX     />>||
    ||//$\                 ~|    REPUBLIC OF INDIA   |~               /$\\||
    ||(100)===================   ONE HUNDRED RUPEES =================(100)||
    ||\\$//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\$//||
    ||====================================================================||
    [edit] Just realized I posted C code in the C++ forum. However, the OP mentioned C/C++ (and used 'C' print statements), so hopefully this example will illustrate the point regardless of language.
    Last edited by Matticus; 02-26-2014 at 08:43 AM.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    or you could use C++11 raw string literals.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by Elkvis View Post
    or you could use C++11 raw string literals.
    This is probably the best option. With this feature we nearly get heredocs in C++. Not quite, because in this example there is an unwanted newline at the beginning of the output. But other than that, it is a nice solution. Of course, this will probably break most syntax highlighting systems for quite some time (including the one on this website):

    Code:
    #include <cstdio>
    
    using namespace std;
    
    int main()
    {
        printf(R"EOF(
    ||====================================================================||
    ||//$\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//$\\||
    ||(100)==================| RESERVE BANK OF INDIA|================(100)||
    ||\\$//        ~         '------========--------'                \\$//||
    ||<< /        /$\              // ____ \\                         \ >>||
    ||>>|        //L\\            // ///..) \\              XXXX       |<<||
    ||<<|        \\ //           || <||  >\  ||                        |>>||
    ||>>|         \$/            ||  $$ --/  ||          XXXXXXXXX     |<<||
    ||<<|     Free to Use        *\\  |\_/  //*                        |>>||
    ||>>|                         *\\/___\_//*                         |<<||
    ||<<\      Rating: E     _____/ M GANDHI \________    XX XXXXX     />>||
    ||//$\                 ~|    REPUBLIC OF INDIA   |~               /$\\||
    ||(100)===================   ONE HUNDRED RUPEES =================(100)||
    ||\\$//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\$//||
    ||====================================================================||
    )EOF");
    
    }

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by c99tutorial View Post
    this will probably break most syntax highlighting systems for quite some time (including the one on this website)
    Eclipse handles raw string literals correctly. I'm not sure about other IDEs, but I am pretty happy with Eclipse, despite its poor general performance.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  7. #7
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    With this feature we nearly get heredocs in C++. Not quite, because in this example there is an unwanted newline at the beginning of the output.
    O_o

    If having raw text is important enough to force a dependency on C++11 literals, you may as well use a trim.

    [Edit]
    Explanation:

    The second argument for the conversion function "cooking" a string literal is required by the standard, but a few bugs are wondering around existing implementations hence the unused, default parameter.
    [/Edit]

    Soma

    Code:
    #include <iostream>
    #include <string>
    
    std::string operator "" _trimmed
    (
        const char * f
      , unsigned int = 0 /* may need explanation */
    )
    {
        using namespace std;
        string sResult(f);
        string::size_type fOrigin((f[0] == '\n') ? 1 : 0);
        string::size_type fTerminus(sResult.find_last_not_of(" \t\r\n"));
        fTerminus = (fTerminus == (sResult.length() - 1)) ? (fTerminus + 1) : fTerminus;
        return(sResult.substr(fOrigin, fTerminus));
    }
    
    int main()
    {
        using namespace std;
        std::cout <<
    R"EOF(
    ||====================================================================||
    ||//$\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//$\\||
    ||(100)==================| RESERVE BANK OF INDIA|================(100)||
    ||\\$//        ~         '------========--------'                \\$//||
    ||<< /        /$\              // ____ \\                         \ >>||
    ||>>|        //L\\            // ///..) \\              XXXX       |<<||
    ||<<|        \\ //           || <||  >\  ||                        |>>||
    ||>>|         \$/            ||  $$ --/  ||          XXXXXXXXX     |<<||
    ||<<|     Free to Use        *\\  |\_/  //*                        |>>||
    ||>>|                         *\\/___\_//*                         |<<||
    ||<<\      Rating: E     _____/ M GANDHI \________    XX XXXXX     />>||
    ||//$\                 ~|    REPUBLIC OF INDIA   |~               /$\\||
    ||(100)===================   ONE HUNDRED RUPEES =================(100)||
    ||\\$//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\$//||
    ||====================================================================||
    )EOF"_trimmed
        ;
        return(0);
    }
    Last edited by phantomotap; 02-26-2014 at 04:20 PM.
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  8. #8
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,750
    You could also use xxd if you have linux, unix or OSX (it probably compiles on Windows as well... the source code is a single .c file)

    Code:
    $ xxd -i asciipic.txt                                   
    unsigned char asciipic_txt[] = {                                                
      0x7c, 0x7c, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
    
      <.... snipped ....>
    
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x7c, 0x7c, 0x0a
    };
    unsigned int asciipic_txt_len = 1095;
    Not that this array is not NULL terminated. To do that, add 0x00 to the end of the array. Once it's NULL terminated and because you're going to be using it as a string you can delete the unsigned int asciipic_txt_len = 1095 line.

    Code:
    #include <stdio.h>
    
    static unsigned char asciipic_txt[] = {                                                
      0x7c, 0x7c, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x7c, 0x7c,       
      0x0a, 0x7c, 0x7c, 0x2f, 0x2f, 0x24, 0x5c, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c,       
      0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c,       
      0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c,       
      0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c,       
      0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c,       
      0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x2f, 0x24, 0x5c, 0x5c, 0x7c,       
      0x7c, 0x0a, 0x7c, 0x7c, 0x28, 0x31, 0x30, 0x30, 0x29, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x7c, 0x20, 0x52, 0x45, 0x53, 0x45, 0x52, 0x56, 0x45,       
      0x20, 0x42, 0x41, 0x4e, 0x4b, 0x20, 0x4f, 0x46, 0x20, 0x49, 0x4e, 0x44,       
      0x49, 0x41, 0x7c, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,       
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x28, 0x31, 0x30, 0x30, 0x29,
      0x7c, 0x7c, 0x0a, 0x7c, 0x7c, 0x5c, 0x5c, 0x24, 0x2f, 0x2f, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7e, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x27, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x3d,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
      0x2d, 0x2d, 0x2d, 0x27, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x5c, 0x24, 0x2f,
      0x2f, 0x7c, 0x7c, 0x0a, 0x7c, 0x7c, 0x3c, 0x3c, 0x20, 0x2f, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x24, 0x5c, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f,
      0x2f, 0x20, 0x5f, 0x5f, 0x5f, 0x5f, 0x20, 0x5c, 0x5c, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x20,
      0x3e, 0x3e, 0x7c, 0x7c, 0x0a, 0x7c, 0x7c, 0x3e, 0x3e, 0x7c, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x4c, 0x5c, 0x5c, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f,
      0x2f, 0x20, 0x2f, 0x2f, 0x2f, 0x2e, 0x2e, 0x29, 0x20, 0x5c, 0x5c, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x58, 0x58, 0x58, 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x7c, 0x3c, 0x3c, 0x7c, 0x7c, 0x0a, 0x7c, 0x7c, 0x3c, 0x3c, 0x7c, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x5c, 0x20, 0x2f, 0x2f,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c,
      0x7c, 0x20, 0x3c, 0x7c, 0x7c, 0x20, 0x20, 0x3e, 0x5c, 0x20, 0x20, 0x7c,
      0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x7c, 0x3e, 0x3e, 0x7c, 0x7c, 0x0a, 0x7c, 0x7c, 0x3e, 0x3e, 0x7c,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x24, 0x2f,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x7c, 0x7c, 0x20, 0x20, 0x24, 0x24, 0x20, 0x2d, 0x2d, 0x2f, 0x20, 0x20,
      0x7c, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x7c, 0x3c, 0x3c, 0x7c, 0x7c, 0x0a, 0x7c, 0x7c, 0x3c, 0x3c,
      0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20, 0x74,
      0x6f, 0x20, 0x55, 0x73, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x2a, 0x5c, 0x5c, 0x20, 0x20, 0x7c, 0x5c, 0x5f, 0x2f, 0x20, 0x20,
      0x2f, 0x2f, 0x2a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x7c, 0x3e, 0x3e, 0x7c, 0x7c, 0x0a, 0x7c, 0x7c, 0x3e,
      0x3e, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x2a, 0x5c, 0x5c, 0x2f, 0x5f, 0x5f, 0x5f, 0x5c, 0x5f,
      0x2f, 0x2f, 0x2a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x7c, 0x3c, 0x3c, 0x7c, 0x7c, 0x0a, 0x7c, 0x7c,
      0x3c, 0x3c, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x61, 0x74,
      0x69, 0x6e, 0x67, 0x3a, 0x20, 0x45, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f,
      0x5f, 0x5f, 0x5f, 0x5f, 0x2f, 0x20, 0x4d, 0x20, 0x47, 0x41, 0x4e, 0x44,
      0x48, 0x49, 0x20, 0x5c, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f,
      0x20, 0x20, 0x20, 0x20, 0x58, 0x58, 0x20, 0x58, 0x58, 0x58, 0x58, 0x58,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x3e, 0x3e, 0x7c, 0x7c, 0x0a, 0x7c,
      0x7c, 0x2f, 0x2f, 0x24, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7e, 0x7c,
      0x20, 0x20, 0x20, 0x20, 0x52, 0x45, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43,
      0x20, 0x4f, 0x46, 0x20, 0x49, 0x4e, 0x44, 0x49, 0x41, 0x20, 0x20, 0x20,
      0x7c, 0x7e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
      0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x24, 0x5c, 0x5c, 0x7c, 0x7c, 0x0a,
      0x7c, 0x7c, 0x28, 0x31, 0x30, 0x30, 0x29, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x3d, 0x3d, 0x20, 0x20, 0x20, 0x4f, 0x4e, 0x45, 0x20, 0x48, 0x55, 0x4e,
      0x44, 0x52, 0x45, 0x44, 0x20, 0x52, 0x55, 0x50, 0x45, 0x45, 0x53, 0x20,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x28, 0x31, 0x30, 0x30, 0x29, 0x7c, 0x7c,
      0x0a, 0x7c, 0x7c, 0x5c, 0x5c, 0x24, 0x2f, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f,
      0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f,
      0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f,
      0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f,
      0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f,
      0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x2f, 0x5c, 0x5c, 0x24, 0x2f, 0x2f, 0x7c,
      0x7c, 0x0a, 0x7c, 0x7c, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
      0x7c, 0x7c, 0x0a, 0x00
    };
    
    int main(void)
    {
        printf("%s\n", asciipic_txt);
        return 0;
    }
    I know this is in the C++ section and I've used C, but my point is more about xxd than C or C++ so I think it's still relevant.

  9. #9
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    You could also use xxd if you have linux, unix or OSX
    O_o

    I'd strongly advise against the original poster using such a tool. (Not that such a tool is bad.) Such tools have been a staple of programmer education for a very long time. I'd suggest that the original poster write the tool.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using ascii value
    By parisframe in forum C Programming
    Replies: 7
    Last Post: 09-21-2009, 08:42 PM
  2. Ascii to Hex
    By bobthebullet990 in forum C Programming
    Replies: 8
    Last Post: 08-31-2007, 04:42 AM
  3. I need ASCII art.
    By sea_4_ever in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 08-29-2007, 11:55 AM
  4. ASCII character with ASCII value 0 and 32
    By hitesh_best in forum C Programming
    Replies: 4
    Last Post: 07-24-2007, 09:45 AM
  5. ascii
    By xlordt in forum C Programming
    Replies: 7
    Last Post: 04-11-2002, 05:46 PM

Tags for this Thread