Hi,
For my program I have a function for a wheel of fortune program that takes a line of input from a text file. However, I need to fix it to choose a random line and to break the line up. Could someone help me do this?
Examples:
Line in text file
Before and After%Whitney Houston Texas
Need to break up into string(?) which is the category(Before and after) and actual word (Whitney Houston Texas)
Thanks so much for taking the time to read this.
Code:
/***************************************/
/* initialize_array */
/***************************************/
int initialize_array(char phrase[], char puzzle[]){
FILE* phraseFile = NULL;
char filename[256];
int cnt = 0;
char word[100];
phraseFile = fopen("input-words.txt", "r");
while (!feof(phraseFile)){
char c = ' ';
fscanf(phraseFile, "%c", &c);
if ((int)c < 15) break;
if (c >= 'a' && c <= 'z') /* convert lower case to upper case */{
c = to_upper(c);
}
phrase[cnt] = c; /* place the solution character into the array */
if (c >= 'A' && c <= 'Z'){
puzzle[cnt] = '*';
}
else /* it's not a letter */{
puzzle[cnt] = c;
}
++cnt;
}
return cnt;
}