|
-
Mar 22nd, 2002, 01:22 PM
#1
Thread Starter
Junior Member
Random Access in Text Files
I have an text file that stores the details of objects of an account class. I need to be able to search the text file based on what account number the user has entered. each account number is a 4 digit integer.
I have it working for the first line of a file but i dont know how I can move it on to search the start of the next line of the file. This is the code taht i have so far.
char card[5];
char c;
long int file_pos, last_pos;
string line;
cin >> card;
ifstream in("account.txt") ;
while (!in.eof())
{
getline(in, line);
cout <<line<<endl;
file_pos = line.find(card);
}
Any help would be appreciated. I have not been able to find a tutorial on the web to explain this to me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|