ASCII picture generator program?

This is a discussion on ASCII picture generator program? within the C++ Programming forums, part of the General Programming Boards category; hello all, i am new to this forum and also new to c++. I am taking a programming course right ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    37

    ASCII picture generator program?

    hello all, i am new to this forum and also new to c++. I am taking a programming course right now. My teacher gave us our first assignment and the description is this: i dont even know where to start on how to create a program that can convert this picture into an ascii picture.


    Description : Write a program that displays a smiley face using any ASCII character, and covering more than 5 lines.

    here is the image
    https://cms.psu.edu/Spring2/200708SP...miley.png?8755

    that is the image
    any help is greatly appreciated

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Go State.

    If it's as simple as it sounds, he's just asking you to 'print out' out a picture using a character (many use '*') and cout, using at least 5 new lines to create the smiley. As many others will tell you, how would you do it on paper, or using your keyboard?

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    37
    nice reppin the psu and scranton, i'm from dunmore

    so basically just draw it using a character and cout it to cmd?

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Yes, sounds like that's all he's asking. These programming courses start out very low level, so I wouldn't read more into that particular assignment.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    37
    i have the program written, i'm just not sure what ur put on int main.

    right now it looks like this, and it wont run

    Code:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        
        cout << "                   ***** " << "\n" ;
     "                          *           *" << "\n";
        "                    *                 * " << "\n";
        "                   *    888     888    * " << "\n";
    "                      *     888     888     * " << "\n";
     "                     *                     * " << "\n";
      "                    *                     * " << "\n";
      "                     *    *         *     * " << "\n";
     "                       *     * * * *      * " << "\n";
     "                          *           * " << "\n";
     "                              ***** " << "\n";
                           
        
        
        
        
        
        return 0;
    }

  6. #6
    Registered User Cpro's Avatar
    Join Date
    Oct 2006
    Posts
    149
    Code:
    cout << "                   ***** " << "\n" ;
    The semi-colon ends the cout line.
    So, you either need to delete all the semi-colons except the last, or add "cout<<" to the beginning of every line. Something like:
    Code:
    cout<<"                              ***** " << "\n" ;
    cout<<"                          *           *" << "\n";
    cout<<"                        *                 * " << "\n";
    cout<<"                       *    888     888    * " << "\n";
    cout<<"                      *     888     888     * " << "\n";
    cout<<"                      *                     * " << "\n";
    cout<<"                      *                     * " << "\n";
    cout<<"                      *    *         *     * " << "\n";
    cout<<"                       *     * * * *      * " << "\n";
    cout<<"                          *           * " << "\n";
    cout<<"                              ***** " << "\n";
    A bit lopsided, but you get the idea.

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    37
    i actualy have that smae thing now, but i run it .. and cmd comes up for like .2 seconds then goes away.. could it be the int main line?

  8. #8
    Registered User Cpro's Avatar
    Join Date
    Oct 2006
    Posts
    149
    It seems to be working for me.
    If you are using Microsoft Visual Studio, make sure you click "Start Without Debugging" instead of "Start Debugging".

  9. #9
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    There's nothing to stop the program from closing at present. Add cin.get(); before return 0 and that'll await input before closing out.

  10. #10
    Registered User
    Join Date
    Jan 2008
    Posts
    37
    thank you that worked

  11. #11
    Emulator
    Join Date
    Feb 2008
    Posts
    43
    This topic is old, but there is a much better solution. You could just print out 1 but typecast it to char. The 1st ASCII character is a smiley face anyway :P. I made something like this a while back. But instead of giving a smiley face, you type in an ASCII number, and you get its corresponding character. But what he suggested was the easy way out, but works. PM me if you want the source code for this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 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
  2. Replies: 11
    Last Post: 03-24-2006, 10:26 AM
  3. Office access in C/C++ NOT VC++!! :)
    By skawky in forum C++ Programming
    Replies: 1
    Last Post: 05-26-2005, 01:43 PM
  4. ascii values for keys
    By acid45 in forum C Programming
    Replies: 2
    Last Post: 05-12-2003, 07:13 AM
  5. Checking ascii values of char input
    By yank in forum C Programming
    Replies: 2
    Last Post: 04-29-2003, 07:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21