Solved

Moving within a File

Posted on 2000-03-25
3
175 Views
Last Modified: 2013-11-20
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?

0
Comment
Question by:Yozzer
3 Comments
 
LVL 2

Expert Comment

by:wyy_cq
Comment Utility
method 1:

move_to_header
for(i=0;i<you_want;read_line())
{
}

method 2:
build a index file to record the position of every line


0
 
LVL 3

Expert Comment

by:ghimireniraj
Comment Utility
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...
0
 
LVL 1

Accepted Solution

by:
YiannisVolos earned 50 total points
Comment Utility
Hi.

You seem to use MFC. If you would be interested in using functions that I created to manipulate data in sequential/linear files you could have a look at my source code and then you could award me :)

I adapted my examples for Visual C++ (Windows) and Turbo C++ for Dos.

If you have any questions concering how the code works please inform me and I'll gladly provide you more help.

The two examples are located at:
http://volosm.arsdigita.org/devzone/dnlds/c_source.zip
(from the c_source.zip the seek.cpp reads sequential files, append.cpp writes sequential files)

and
http://volosm.arsdigita.org/devzone/dnlds/multi.zip
(this is a full VC++ example)

If you have time maybe you could have a look at my website:
http://volosm.arsdigita.org


Thanks.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 76
How to calculate times for developing software? 8 60
List out all word 7 219
EvenOdd challenge 10 81
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now