Lowyat.NET Forums

Welcome Guest ( Log In | Register )

LYN wins Intel-Lenovo-Tangs Blogathon challenge. Thank you everybody!
 
RSS feedBump TopicReply to this topicStart new topicStart Poll

Outline · [ Standard ] · Linear+

> search FILE, C++

dinodragon
post Oct 16 2009, 11:40 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #1


Getting Started
**

Group: Junior Member
Posts: 117
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Apr 2008




any idea how to search certain line in a FILE??

for example, the FILE contain (name, age, gender, academic level)... and i want to parform search base on the (name).. how???

thanks for your help..
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
brian12988
post Oct 21 2009, 12:40 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #2


Looking for ideas for Android programming..
****

Group: Senior Member
Posts: 689
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Jan 2007
From: <T-B-S>





depends on how u want to do it...do u wan to first read the file and then search (which makes it easier.. but not so when u have a networked environment..laugh.gif) or do u want to search the file in real time..much like a random access file..
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
pitok235149
post Oct 27 2009, 01:57 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #3


Newbie
*

Group: New Member
Posts: 3
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Apr 2007
From: Johor-Kinrara




maybe u can use fgetts() to get buffer line by line,and use the buffer and compare it?
e.g:
CODE

FILE out = _ftopen(..);
if(out!=NULL)
{
  while(fgets(buffer,3000,..)!=NULL)//forgot the syntax
  {
       if(_tcsstr(_T("name"),buffer) == 0 || _tcsstr(_T("id"),buffer) == 0)
      {
          //found,so u can use a better function to get the pointer to the exact array,i forgot the name. check it in msdn
      }
  }
}

//please correct me if im wrong

This post has been edited by pitok235149: Oct 27 2009, 02:07 AM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Bump TopicReply to this topicTopic OptionsStart new topic
 



----debug section please ignore----
Lo-Fi Version Time is now: 24th November 2009 - 08:21 PM
All Rights Reserved 2003-2009 Vijandren Ramadass (~living on a prayer~)