C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 7th, 2004, 12:32 AM
carlgotgame carlgotgame is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 2 carlgotgame User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow Displaying a multidimensional array for a game of Tic Tac Toe

I've been working with this code for the last couple days and I can't figure out how to display a multidimensional array using a char array instead of a type int array. Below is the code that I have created. Any feedback would be greatly appreciated. Thanks

//COMPILER DIRECTIVES
#include<iostream>
using namespace std;

//FUNCTION DEFINITIONS
void inform();
void displayArray(char [], char []);

int main()
{
//LOCAL DATA
char TicTacToe [3][3] = {0, 0, 0,
0, 0, 0,
0, 0, 0}; //INITIALIZES AN ARRAY OF 3 ROWS AND 3 COLUMNS

//INFORMATION FOR THE USER
inform();
//DISPLAY THE ARRAY
displayArray(TicTacToe)

return 0;
}//end int main()
//FUNCTION DEFINITIONS
//FUNCTION TO INFORM THE USER
void inform()
{
cout << "This program will demonstrate the use of a multidimensional\n"
<< "array to create a game of Tic Tac Toe!!\n\n\n";
}//end void inform()
//FUNCTION TO DISPLAY THE ARRAY OF A GAME OF TIC TAC TOE
void displayArray(char A[], char B[])
{
for(a = 0; a < 3; a++)
{
for(b = 0; b < 3; b++)

cout << A[a];
cout << B[b];
cout << endl << endl;
}
}//end void displayArray(char A[], char B[])

Reply With Quote
  #2  
Old November 7th, 2004, 04:38 PM
pinzasso pinzasso is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 2 pinzasso User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
First of all void displayArray(char A[], char B[]) is takeing two char arrays, not a single 2 demensional char array

i think the rest of the code would look something like thigs
for(size_t a=0;a<3;i++)
{
for(size_t b=0;a<3;i++)
cout<<chararray[a][b];
cout<<endl;
}

Reply With Quote
  #3  
Old November 7th, 2004, 05:54 PM
carlgotgame carlgotgame is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 2 carlgotgame User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The code worked

Quote:
Originally Posted by pinzasso
First of all void displayArray(char A[], char B[]) is takeing two char arrays, not a single 2 demensional char array

i think the rest of the code would look something like thigs
for(size_t a=0;a<3;i++)
{
for(size_t b=0;a<3;i++)
cout<<chararray[a][b];
cout<<endl;
}

Thanks for the help. I finally got the array to display itself.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Displaying a multidimensional array for a game of Tic Tac Toe


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT