Hi guys

How do I search a file ".txt" which contains three lists side by side for a word ,
then print the line that the word I searched for is in?

-The lists are lists of names .

it would be beter if you show how to do it with 1-D or 2-D arrays .


First - declare a counter variable and set it to zero.
Second - use a while loop with a getline call as your loop condition.
Third - increment the counter variable.
Fourth - see if the word you are looking for is in that line.
Fifth - If it is return the counter variable or if you want to see the entire line the word was found it return that.
Sixth - If not keep the loop going.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.