Solved

What moves the record indicator?

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

Independent Software Vendors: 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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

729 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