[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Moving within a File

Posted on 2000-03-25
3
Medium Priority
?
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:wyy_cq
ID: 2656486
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
ID: 2656861
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 150 total points
ID: 2658038
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 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