954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

drawing - stickman with array

Hello,

as you well know I've got a hangman game produced, I now have the luxury of adding to the code since all my work is completed ...yay, well, I've decieded to take it a step further and draw out the hunged man! I have the drawing , its just putting it into an array... Anyone offer suggestions?
to prove I'm working heres a sample code:

#include <iostream>

using namespace std;

int main()
{
   char array[10] ="_____";
   char array2[10] = "||||";

for(int i =0;  i < 3 ;i++)
{
cout << array[i];
}
cout << endl;
for ( i = 0; i < 3 ; i++)
{
cout << array2[i] <<endl;
}
return 0;
}


just wondering if my way im working on is the best for now?

Acidburn
Posting Pro
511 posts since Dec 2004
Reputation Points: 12
Solved Threads: 5
 

Have an array of chars and draw it!

eg:

char array[] =    { "+", "+", "+", "+", "+",
                         "+", "0", "+", "0", "+",
                         "+", "+", "^", "+", "+",
                         "+", "_", "+", "_", "+",
                         "+", "+", "-", "+", "+" };

int s = sizeof(array) / sizeof(char);

for(int i = 0; i < s; i++)
    cout << array[i];
cout << "\n";


draws a simple smiley face!

1o0oBhP
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 16
Solved Threads: 6
 

Have an array of chars and draw it!

eg:

char array[] =    {      "+", "+", "+", "+", "+",
                         "+", "0", "+", "0", "+",
                         "+", "+", "^", "+", "+",
                         "+", "_", "+", "_", "+",
                         "+", "+", "-", "+", "+" };

int s = sizeof(array) / sizeof(char);

for(int i = 0; i < s; i++)
    cout << array[i];
cout << "\n";


draws a simple smiley face!

sorry for repost, was supposed to be an edit!

1o0oBhP
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 16
Solved Threads: 6
 

when I attempt to run it i get an error "To mnay intilizers, but when I change the " to ' it runs but doesnt print on sepearte lines ?

Acidburn
Posting Pro
511 posts since Dec 2004
Reputation Points: 12
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You