I'm making a word search program in C which takes the user input and then chooses one of the global arrays of words and uses that to generate the word search. It works when I just use one of the global arrays but not with the choice, I want to copy the contents of the category arrays, depending on the users choice into the newArray which can be used with the word search. The program crashes after entering an option at the moment, here's what I have.
switch(choice)
{
case 1: choseArray(newArray, massEffect);
break;
case 2: choseArray(newArray, fallout3);
break;
case 3: choseArray(newArray, elderScrolls);
break;
case 4: choseArray(newArray, gameOfThrones);
break;
case 5: choseArray(newArray, breakingBad);
break;
default: printf("Enter a valid option!");
}
void choseArray(char** newArray, char** category)
{
int i;
for(i=0;i<6;i++)
{
strcpy(newArray[i], category[i]);
}
}
The arrays look like this and are declared globally for now
char gameOfThrones[6][250] = {"KINGSLANDING", "TYRIAN", "STARK", "LANISTERS", "WESTEROS", "WINTERFELL"};
char breakingBad[6][250] = {"JESSE", "WALT", "HEISENBERG", "SAUL", "GUSTAVO", "BREAKFAST"};
char newArray[6][250];