# Arrays

• 12-01-2003
H3g3m0n
Arrays
Just a quick question about multidemintional arrays, i understand that when i create them i can put values into them with = {values} however is there anyway to put the values in them the sameway after ive created them (without a loop of somekind)?

Heres the code ive got, FONTHEIGHT and FONTWIDTH are #defines of 8 and 4. chr is just an int.
Code:

```        int FontArray[FONTHEIGHT][FONTWIDTH];         switch (chr)         {                 // H         case 72: FontArray[][] = { {1, 0, 0, 1 },                                               {1, 0, 0, 1 },                                               {1, 0, 0, 1 },                                               {1, 1, 1, 1 },                                               {1, 1, 1, 1 },                                               {1, 0, 0, 1 },                                               {1, 0, 0, 1 },                                               {1, 0, 0, 1 }}; break;         default: FontArray[][] = { {1, 1, 1, 1 },                                             {1, 1, 1, 1 },                                             {1, 0, 0, 1 },                                             {1, 0, 0, 1 },                                             {1, 0, 0, 1 },                                             {1, 0, 0, 1 },                                             {1, 0, 0, 1 },                                             {1, 1, 1, 1 }}; break;         }```
• 12-01-2003
Sang-drax
Re: Arrays
Quote:

Originally posted by H3g3m0n
however is there anyway to put the values in them the sameway after ive created them (without a loop of somekind)?
No.
• 12-01-2003
Salem
You could always use pointers...
Code:

```#include <stdio.h> #include <stdlib.h> #define FONTHEIGHT 8 #define FONTWIDTH  4 int main ( int argc, char *argv[] ) {   int FontArrays[2][FONTHEIGHT][FONTWIDTH] = {     {       {1, 0, 0, 1 },       {1, 0, 0, 1 },       {1, 0, 0, 1 },       {1, 1, 1, 1 },       {1, 1, 1, 1 },       {1, 0, 0, 1 },       {1, 0, 0, 1 },       {1, 0, 0, 1 }     },     {       {1, 1, 1, 1 },       {1, 1, 1, 1 },       {1, 0, 0, 1 },       {1, 0, 0, 1 },       {1, 0, 0, 1 },       {1, 0, 0, 1 },       {1, 0, 0, 1 },       {1, 1, 1, 1 }     },   };   int r, c;   int chr = 72;   int (*fontptr)[FONTWIDTH];   switch (chr)   {       case 72: fontptr = FontArrays[0]; break;       default: fontptr = FontArrays[1]; break;   }   for ( r = 0 ; r < FONTHEIGHT ; r++ ) {     for ( c = 0 ; c < FONTWIDTH ; c++ ) {       printf( "%d", fontptr[r][c] );     }     printf( "\n" );   }   return 0; }```
• 12-02-2003
H3g3m0n
Thanks, I guess ill probally have to find some otherway of retreving them, pointers probally wouldn't work as i would need atleast although many numbers would be returning the same array.
• 12-02-2003
Salem
> although many numbers would be returning the same array.
Like

case 72: case 73: case 74: case 75: fontptr = FontArrays[0]; break;

In fact, why not just go for it and say
fontptr = FontArrays[chr];