I'm at a lost here. I'm suppose to get the data from a text file and put those data into my struct, but I'm confuse on how to do that. I read on cplusplus on different functions I can use but I'm still confuse. From what I understand fgets and fscanf would be the most practical function for my case, but how do I make them read the code and separate the keyword from the definition?
knife - an instrument for cutting
stove - a heat chamber or box for special purposes
cabinet - a piece of furniture with shelves, drawer used for storing items
cutting board - a board used as a firm surface for cutting food
pan - a broad, shallow container of metal used for cooking
Based on your input file, I would
read the line
copy line to key and def
Determine the location of the "-"
use string erase to get rid of unwanted chars.
I got this to work. I used fgets to read the file until it can't read anymore. Then I used strtok to split the string into two parts then assign the first part to keyword and the second part to definition.