I have searched many a site to find an answer to this question, so here goes:
(This is actually C, not C++ so bear with me)
I'm doing a hangman program that needs to pull different quotes from a text file named quotes.txt. Each quote is on a different line. I have the entire hangman program written (I can post later, if need be), but I need to write a function to get the quote, calculate the quote length, AND convert the entire quote to uppercase(I thnk I'm fine with that part though)
My variables are as follows:
(X is the length of the quote which will need to be calculated)
char realquote[x] contains the quote as it is written in the text file.
char quote[x] contains the quote written in all capitals
The function begins as follows:
1 2 3 4
|
void GetQuote()
{
//This is where I need code to pull the quote
}
|
I will have approximately 10 quotes stored in the text file (One per line, as mentioned before). I would like to generate a random number between 1 and 10 and pull the quote from that line into the realquote array. I then need to determine the actual string length (I'm assuming I will use strlen or something like that?).
Any and all help with this would be greatly appreciated. Like I said, I can post up the entire Hangman program so you can see how it fits in, but I believe I've provided all relevant information to this specific part!
Thanks!
Madd0g