Solved

What moves the record indicator?

Posted on 2002-04-04
2
200 Views
Last Modified: 2010-04-02
I am a novice at C++ and am just learning the language and am getting into files, hence my question.  

When reading a file, what moves the record indicator to the next record?  I have been introduced to structs, but this question is before structs.

Thanks.
0
Comment
Question by:cccgsmith
[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
2 Comments
 
LVL 1

Accepted Solution

by:
bluprint earned 100 total points
ID: 6919002
It depends on how you read the file. Generally speaking, when a file is opened, there is a pointer that points to the beginning of the file.

If a particular function or operator will "read a line", it reads until it finds a "newline" character, it then moves the pointer to the character after the newline character (which is the beginning of the next line).

In some cases, there are functions which will read one character at a time, instead of a line at a time. In this case, the pointer moves along one character at a time, and the function returns after reading one character.

So, to be sure and answer your question:
"what moves the record indicator to the next record", the answer is:

Since the entire file is stored (on the HD) in such a way that there is really no such thing as "the next record" in the file (there is only a series of bytes, without much meaning), there is only an indicator (newline character) that tells where the current line ends, and the next begins. This indicator is then used by editors, programming languages, etc. to provide a common indicator as to what constitutes a new line.

By the way, the particular character used to indicate a newline varies depending on OS. For Unix based systems, it's typically the value 0A in hex, which is a newline or line-feed character (both names are used).

For Windows however, there a two-character sequence is used to signify a newline, 0A0D, which is line-feed followed by a carriage return.


0
 
LVL 1

Author Comment

by:cccgsmith
ID: 6919087
Good answer.  Since the newline character is invisible, I forgot about it, hence my problem in comprehending what was taking place.

Thanks.
 
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

630 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