Solved

What moves the record indicator?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

863 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

24 Experts available now in Live!

Get 1:1 Help Now