943,758 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 5456
  • C++ RSS
Apr 5th, 2005
0

drawing - stickman with array

Expand Post »
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:

C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char array[10] ="_____";
  8. char array2[10] = "||||";
  9.  
  10. for(int i =0; i < 3 ;i++)
  11. {
  12. cout << array[i];
  13. }
  14. cout << endl;
  15. for ( i = 0; i < 3 ; i++)
  16. {
  17. cout << array2[i] <<endl;
  18. }
  19. return 0;
  20. }

just wondering if my way im working on is the best for now?
Similar Threads
Reputation Points: 12
Solved Threads: 5
Posting Pro
Acidburn is offline Offline
510 posts
since Dec 2004
Apr 7th, 2005
0

Re: drawing - stickman with array

Have an array of chars and draw it!

eg:

C++ Syntax (Toggle Plain Text)
  1.  
  2. char array[] = { "+", "+", "+", "+", "+",
  3. "+", "0", "+", "0", "+",
  4. "+", "+", "^", "+", "+",
  5. "+", "_", "+", "_", "+",
  6. "+", "+", "-", "+", "+" };
  7.  
  8. int s = sizeof(array) / sizeof(char);
  9.  
  10. for(int i = 0; i < s; i++)
  11. cout << array[i];
  12. cout << "\n";

draws a simple smiley face!
Reputation Points: 16
Solved Threads: 6
Posting Pro in Training
1o0oBhP is offline Offline
445 posts
since Dec 2004
Apr 7th, 2005
0

Re: drawing - stickman with array

Have an array of chars and draw it!

eg:

C++ Syntax (Toggle Plain Text)
  1.  
  2. char array[] = { "+", "+", "+", "+", "+",
  3. "+", "0", "+", "0", "+",
  4. "+", "+", "^", "+", "+",
  5. "+", "_", "+", "_", "+",
  6. "+", "+", "-", "+", "+" };
  7.  
  8. int s = sizeof(array) / sizeof(char);
  9.  
  10. for(int i = 0; i < s; i++)
  11. cout << array[i];
  12. cout << "\n";

draws a simple smiley face!

sorry for repost, was supposed to be an edit!
Reputation Points: 16
Solved Threads: 6
Posting Pro in Training
1o0oBhP is offline Offline
445 posts
since Dec 2004
Apr 7th, 2005
0

Re: drawing - stickman with array

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 ?
Reputation Points: 12
Solved Threads: 5
Posting Pro
Acidburn is offline Offline
510 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Calculations
Next Thread in C++ Forum Timeline: what is the error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC