So I've been learning C and getting really confused on string arrays and pointers.  

I am trying to pass in an array into buildArrays and populate it and use it back in main. When I print the array at the end of buildArrays it prints fine, but when I print it at the end of the main function, the index 0 string prints fine then the rest are off.

```
void buildArrays(char *fileName, char wordArray[][50], char gridArray[][50],int columnCounter, int rowCounter ) {

  FILE *dat2; // Create File objects for input and output file .
  dat2 = fopen(fileName, "r");

  char mystring[columnCounter * 3];
  int c, columnIndex = 0, rowIndex =0;
  while(fgets(mystring, (columnCounter * 3), dat2) != NULL) {

        // printf("Line: %s\n",mystring);
        // printf("rowIndex: %d - rowCounter: %d\n", rowIndex, rowCounter);
        // printf("...\n");

        if(rowIndex < rowCounter){
          strcpy(gridArray[rowIndex], mystring);
          //printf("GridArray: %s\n", gridArray[rowIndex]);
        }
      rowIndex++;
    }
     for(int b=0; b<rowCounter; b++)
   {
      printf("%s\n", gridArray[b]);
   }

}

int main(void)
{
  int rowCounter, columnCounter , wordCounter= 0;
  char fileName[100] = "data1";
  getArraySize(fileName, &columnCounter, &rowCounter, &wordCounter);
  printf("%d x %d", columnCounter, rowCounter);
  printf("Number of words: %d", wordCounter);
  printf("\n");

  char wordArray[wordCounter][columnCounter + 1];
  char gridArray[columnCounter][rowCounter * 2];

  buildArrays(fileName, wordArray, gridArray, columnCounter, rowCounter);

  for(int b=0; b<rowCounter; b++)
   {
      printf("%s\n", gridArray[b]);
   }

}

```

buildArrays print

```
S T E L B M T F E Y D E E P S R T C I A E E

N N E L I T R L B D E T A R E M U N E T Y L

N O I T A N I M I R C N I F L E S S E N T A

A U I D E W A R R A N T N U P R U S S E R P

P G S G E A L P A P B A N P S A S S N M E A

C O N S I T U T I O N D E E C W S O O H P D

S V W D E L A N E E J A M E S M A D I S O N

A E D E S N E G R J C U L T N O H L T I R A

A R C E R R T R E E S B O N E E I D N N P R

S N J U D I C I A L A S S E C O R P E U D I

S M R A R A E B W B E S S M E O A U V P E M

O E O I A I L N O U C D O D S S E N N I G R

L N I D G Y T R C O M P E N S A T I O N N D

D T O Z E H P Y N D R L E E A O H S C O I B

I T P S U E T G O L U Z M M R B E H P I R T

E O I E A R R S U U I B H A Y L L M S T F A

R I N R E E E F U T L V Q U A R T E R I N G

S I D B S R R D I Y E N I G M I A N A T I R

S Q I S E B S C N S P E E C H R O T A E Y N

D L C M I L I T I A F L R N C A T S S P S E

R U T E D Y L E B I L C O H M L E T E S Y Y

L S T R T E W Z L I O S A E N S A E I Y A L

```

main print

```
S T E L B M T F E Y D E E P S R T C I A E E

T Y L

S S E N T A

U P R U S S E R P

B A N P S A S S N M E A

T I O N D E E C W S O O H P D

E L A N E E J A M E S M A D I S O N

E D E S N E G R J C U L T N O H L T I R A

P R

P E U D I

E O A U V P E M

D O D S S E N N I G R

C O M P E N S A T I O N N D

H P Y N D R L E E A O H S C O I B

P S U E T G O L U Z M M R B E H P I R T

A

R I N G

I A N A T I R

```