Yozzer
asked on
Moving within a File
If you have a linear file
as in the following
bof
john martin
bill jones
mark smith
eof
how do you move to a particular line.
e.g in the example above how would i
move to just before the name jones.
i've tried CFile::Seek() but that just
moves to the offset position in bytes
any ideas?
as in the following
bof
john martin
bill jones
mark smith
eof
how do you move to a particular line.
e.g in the example above how would i
move to just before the name jones.
i've tried CFile::Seek() but that just
moves to the offset position in bytes
any ideas?
What do you want to do move to the fist char of every next line..
just keep reading every character in the file from the begining and skip it till you get a "\n"
like
int length;
length=file1.GetLength();
//get length of file in length;
char abc;
while(length)
{
do
{
file1.Read(abc,1);
length--;
}
while(abc=="\n");
///
/* this is the place where you get to the begining of all new lines */
}
well if this is what you want...
just keep reading every character in the file from the begining and skip it till you get a "\n"
like
int length;
length=file1.GetLength();
//get length of file in length;
char abc;
while(length)
{
do
{
file1.Read(abc,1);
length--;
}
while(abc=="\n");
///
/* this is the place where you get to the begining of all new lines */
}
well if this is what you want...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
move_to_header
for(i=0;i<you_want;read_li
{
}
method 2:
build a index file to record the position of every line