954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How do I search a Data File using array?

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?

NOTE:
-The lists are lists of names .

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

thanks

aliyami90
Newbie Poster
4 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

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.

NathanOliver
Veteran Poster
1,084 posts since Apr 2009
Reputation Points: 215
Solved Threads: 189
 

thnx for ur help

aliyami90
Newbie Poster
4 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: