Code:
int Get_Word(){
........//gets random number using the WordCount function and then goes into the dictionary
........//text file and pulls out the word that corresponds to the random number
..........
................int N_Num = WordCount();
................int i, number;
................char SecretWord[15];
..........
........//Random number generator
........srand(time(NULL));
................number = rand() % N_Num;
..........
........//opens file
........FILE*dict = fopen("dictionary.txt", "r");
..........
........//gets the ord from the dictionary file using the random number picked
........for(i=0;.. i <= number; i++){
................fgets(SecretWord, 15, dict);
................}
........fclose(dict);//closes file
..........
..........
return SecretWord;
}
you declare that the function return an integer, yet you return the pointer to a char array. Btw, don't do that either, you 're creating char inside that function, once return, it will go out of scope ( hence the warning regarding local variable). It's better if you pass in a char pointer and return nothing. Example:
Code:
void GetWord(char * SecredWord)