2D arrays and storing characters
I want to read in a file of characters and store each character inside a 2D array. The array will be 8x8 and the file will always contain the same dimensions of characters. I want to treat the array as a 1D array, access the memory allocated for it at array[0][0] and start filling it all the way up to
array[7][7]. I don't want to use two for loops, with subscripting like [0][0], just look it as an array from 0-63, array[63] would be the last element....but only in memory, in reality it would still be a 2D array. How can I access the beginning of the array all the way to the end element by element? Will using array[0], array[1] etc.. just give me the entire row? Any help would be appreciated.
Code:
char actual_array[8][8];
int arr* = &actual_array[0][0]; //pointer to the beginning or the array
int j = 0;
while( (ch = fgetc( theFile )) != feof( input ) )
{
if( j < (8*8) )
{
arr[ j++ ] = ch; //is this right? can I advance the pointer like this?
}
}