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
Solved

What moves the record indicator?

Posted on 2002-04-04
2
197 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

856 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