Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

Array Displayer

Display your little helpful snippets of code that may help us all get something done

Array Displayer

Postby Hellish Designs on Fri Jul 10, 2009 12:44 am

oooxo
oxxxo
oxooo
xxooo
ooooo
Code: Select all
#include <iostream>
using namespace std;

int main()
{
   char Map[5][5] =
   {
      { 'o', 'o', 'o', 'x', 'o'},
      { 'o', 'x', 'x', 'x', 'o'},
      { 'o', 'x', 'o', 'o', 'o'},
      { 'x', 'x', 'o', 'o', 'o'},
      { 'o', 'o', 'o', 'o', 'o'}
   };
   int C=0,R=0;
   for(C;C<(sizeof(Map)/sizeof(*Map));C++)
   {
      R=0;
      for(R;R<((sizeof(*Map)/sizeof(**Map)));R++)
      {
         cout<<Map[C][R];
      }
      cout << endl;
   }
   char t;
   cin>>t;
   return 0;
}

Note: (sizeof(arr)/sizeof(*arr)) && (sizeof(*arr)/sizeof(**arr)) was not by me. I found it on some c++ website. ^.^
This detects how wide and tall the Array is and display's it's contents out into the console.
Hellish Designs
 
Posts: 1
Joined: Thu Jul 09, 2009 5:23 pm

Re: Array Displayer

Postby glinka57 on Sun Aug 30, 2009 9:08 pm

nice
. tic tac toe anyone?
User avatar
glinka57
 
Posts: 158
Joined: Fri Feb 27, 2009 7:32 pm


Return to Snippets

Who is online

Users browsing this forum: No registered users and 0 guests