Hey. So I am not very good at C Programming and need a little help.
I have written a random number generator program which I need to use to randomly pick a word from my dictionary text file. However, I am not sure how to write the part that retrieves the word from the text file. Here is what i have so far. Any help would be greatly appreciated.
insert
Code:
#include <stdio.h>
#include <stdlib.h>
int RandomWordSelection(void){
//picks a random number between 1 and the max_words in the dictionary file
int max = 50;
int i, number;
srand(time(NULL));
for(i = 0; i <= 50; i++);
number = ((float)rand())/RAND_MAX*50+1;
return number;
}
char GetsWord(void){
//Gets the number word from the dictionary that was selected by
// the random number generator
int i, x;
char SecretWord;
int RandomWordSelection(void);
i = RandomWordSelection();
FILE*fptr = fopen("dictionary.txt", "r");
//Not sure how to proceed at this point
return SecretWord;
}