Solved

What moves the record indicator?

Posted on 2002-04-04
2
193 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

744 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

14 Experts available now in Live!

Get 1:1 Help Now