you all helped me with a nice little programming tip earlier in the year, now i have another question :> I think you'll find it quite easy.
I am reading a file in from the hard drive. Here is what it looks like:
I successfully read in Dan Brown, and then "The_Davinci_Code into my linked listCode:Dan Brown The_Da_Vinci_Code This historical fiction thriller chronicles the adventures of Robert Langdon a Harvard professor who gets caught up in the mystery involving the Priory of Sion an organization reputed of keeping a secret with regards to the very foundations of Christianity END_BOOK_SUMMARY
(here is the code I used)
Code:fscanf(fp, "%s", temp->authorFirst); fscanf(fp, "%s", temp->authorLast); fgets(temp->booktitle, MAX_BOOK_LENGTH, fp);
Ok, here's my question:
the reason the above 3 lines of code worked, is because they stopped reading at newline. I want to read in the description of the book (starting with: The historical fiction...) in from the file word by word, stopping at whitespace. With each word, send it to my binary tree function before looking at the next word.
Whats the easiest way to do it?
I examined fscanf, this will let me read in character by character.. and research shows that it will stop reading at white space. But this brings the problem, how do I store these characters until white space is read in? I would say an array could do this, but all the words are different lengths. Its either a very tricky algorithm or theres a string function I don't know about.
Thanks for any help u can offer me :>