reading text from a file
I'm new to programming and I have a question about reading text from a file and I don't know how would be the best way to do it. For example I have a text file containing a few words or numbers placed in this way as below:
Now if I want to get only the word oranges out of it, which function should I use? Would it be better to read the characters into a 2D array? If I was to do that using say fgetch() how would I specify on which row the word oranges would begin?
Thank you and I appreciate your help.
Start by reading each line with fgets().
Then use various string comparison functions to determine what you read.
Then perhaps use some kind of state (foundNumber, foundFruit) to keep track of where you are.
Also perhaps a counter for how many fruit you've seen.