Helo..here i want to read data from a text file arranged in single column like:
dog
cow
crocodile
monkey
-and assign it to a string called 'string product'. Later i have to write code somemore to ask the user to type a word and search for that word in string product that i assign with data from file. So as a first step i typed a program like shown below but cant see anything when compile. may i know what is my wrong and suggestion to correct it. i am a beginner only.
If the file looks like your example, you can use getline(open1,product[n]); http://www.cplusplus.com/reference/iostream/istream/getline.html. And you're printing the first thousand element of product[], while this array may consist out of more or less filled elements. Maybe adding a variable to keep track of the number of words? (There're more gentle, efficentic solutions, like vectors, but if you're a beginner, I woud stay away from that).