473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help me to solve this C++ problem

Question

The road and traffic authority for a small country currently uses a
system to store information about all 'currently' licensed drivers.

A licensed driver has the following info stored about them in a
record;
1. Given name(s) of the license holder.(not more than 128 char (may
have spaces)).
2. Surname of the license holder.(Not more then 128 same like above).
3. Driver license number.
4. The sex of the license holder.
5. The residental address of the license holder.(Not more then
128)same.
6. The registration number of the car the license holder drivers.(A
combination of char and numbers. The string must be six long.)

The current system allow users to add new license holders, modify
details about prexisting license holders and remove a license holder
by entering the license number.

Your job is to write a C++ program to replace the pre-existing system.
In doing so your program must;

1.Allow user to add new license holders to the system.
2.Allow user to remove the license holder from the system.
3. Allow the users to search on a license number, display and
potentially modify a matched record.

The program is an interactive and menu driven. A user can choose from
a set of options to perform a particular action. It also to has
persistent storage.Each license holder has one record in the system.
Records a fixed lenght, therefore the C++ type string cannot be used
in the implementation. The first time the program is run, there is no
data file in the file system. The file is a randoom access file used
to store a collection of records about liccense holders. The name of
this file is data.dat.

If the file already exists when the program starts, you are to read
the all records from the file, into array of records. You can assume
the maximum size of the array is 500. That is at any given time, your
system can hold a maximum of 500 license holders.

During runtime a user may add new license records.When a user adds a
new record, the program prompt the user to enter all details relevent
to the record. The record is inserted into the first available slot in
the array of records and written to the file immediately at the
correseponding record location. If there are no available records an
error is to be printed.

When a user removes a record, all elements of the record are cleared
and the record is marked as available. The corresponding record in the
file is then marked available.

Users can search/dispaly/modify a record. The search key is the
license number. If there is a record with the license number matching
the specified key, the record is displayed and the user given the
option of modifying the record. A user can search for a record and
display it without performing any modifications.

Your program should perform the appropriate checks to ensure valid
input at ALL time.
Jul 22 '05 #1
20 2626

"titi" <ww****@yahoo.com> wrote in message
news:bf**************************@posting.google.c om...
Question

The road and traffic authority for a small country currently uses a
system to store information about all 'currently' licensed drivers.


<SNIP>

Please do not post homework questions.

http://www.parashift.com/c++-faq-lit...t.html#faq-5.2

Regards,
Sumit.
Jul 22 '05 #2
On 8 Feb 2004 06:51:41 -0800
ww****@yahoo.com (titi) wrote:

Did you read the question before you posted it? Specifically:
Your job is to write a C++ program to replace the pre-existing system.

^^^^

When you have a specific problem with *your* program then post the
smallest relevant snippet of compilable code that you're having problems
with, along with the input, expected output and actual output you're
getting. We don't do homework here!

Regards,

Matt.
Jul 22 '05 #3
titi writes:
The road and traffic authority for a small country currently uses a
system to store information about all 'currently' licensed drivers.

<snip>

This is going to take some time. I think a common mistake of beginners is
trying to do it "right" in the first attempt. This results in a lot of
typing, a lot of syntax errors, and a lot of fussing over details of things
that eventually get thrown away; with the result of wasting huge amounts of
time. (For example the warning about checking for valid data.) I would
start with only a minimal subset of data fields. Last name, simple one part
name such as Smith (as distinct from von Neuman) and license number might
be enough. BTW the thing about the old existing program seems to be mainly
noise to confuse you. Get the simple thing working to establish confidence
that the paths and methods will work, then start fleshing it out with
details. Note that a surname can change when a woman marries. I see a
menu, a class to hold the data and an ordinary array of these classes in
*main*. Note that C++ often defaults to do the opposite of what you expect
WRT white space.

This program is going to be 90% bulk and 10% useful and interesting "stuff".
Jul 22 '05 #4

"osmium" <r1********@comcast.net> wrote in message
news:c0*************@ID-179017.news.uni-berlin.de...
titi writes:
The road and traffic authority for a small country currently uses a
system to store information about all 'currently' licensed drivers. <snip>

This is going to take some time. I think a common mistake of beginners is
trying to do it "right" in the first attempt. This results in a lot of
typing, a lot of syntax errors, and a lot of fussing over details of

things that eventually get thrown away; with the result of wasting huge amounts of time.


It's no use, no only do newbies always make this mistake, they never, ever
listen to anyone who tells them to do different. At least that's my
experience from this newsgroup.

john

Jul 22 '05 #5

"titi" <ww****@yahoo.com> wrote in message
news:bf**************************@posting.google.c om...
Question
The below is not a question, but apparently simply a
reproduction of your assignment.

Go ahead and try to do it (break it down into small pieces,
then you won't be overwhelmed).

I've inserted a few general remarks below.
The road and traffic authority for a small country currently uses a
system to store information about all 'currently' licensed drivers.

A licensed driver has the following info stored about them in a
record;
1. Given name(s) of the license holder.(not more than 128 char (may
have spaces)).
2. Surname of the license holder.(Not more then 128 same like above).
3. Driver license number.
4. The sex of the license holder.
5. The residental address of the license holder.(Not more then
128)same. 6. The registration number of the car the license holder drivers.(A
combination of char and numbers. The string must be six long.)
Hmm, I own four automobiles, and drive each at various times.
I wonder how that's supposed to be handled ? :-)

The current system allow users to add new license holders, modify
details about prexisting license holders and remove a license holder
by entering the license number.

Your job is to write a C++ program to replace the pre-existing system.
In doing so your program must;

1.Allow user to add new license holders to the system.
2.Allow user to remove the license holder from the system.
3. Allow the users to search on a license number, display and
potentially modify a matched record.

The program is an interactive and menu driven. A user can choose from
a set of options to perform a particular action. It also to has
persistent storage.Each license holder has one record in the system. Records a fixed lenght, therefore the C++ type string cannot be used
in the implementation.

I see nothing in this specification that would prevent using the
std::string type to represent textual data.
The first time the program is run, there is no
data file in the file system. The file is a randoom access file used
to store a collection of records about liccense holders. The name of
this file is data.dat.

If the file already exists when the program starts, you are to read
the all records from the file, into array of records.
The preferred "C++ way" of storing such 'collections' of same-type
objects is to use a container (e.g. std::vector) rather than an
array. But I suppose you should go ahead and use an array, if
it's required by the assignment.

You can assume
the maximum size of the array is 500. That is at any given time, your
system can hold a maximum of 500 license holders.
Note: using a container would eliminate the need for such an
arbitrary restriction. (Yes, an array could be dynamically
allocated, and expanded as needed, but that gets to be a mess
rather quickly.) Containers Are Cool. :-)
During runtime a user may add new license records.When a user adds a
new record, the program prompt the user to enter all details relevent
to the record. The record is inserted into the first available slot in
the array of records and written to the file immediately at the
correseponding record location. If there are no available records an
error is to be printed.

When a user removes a record, all elements of the record are cleared
and the record is marked as available. The corresponding record in the
file is then marked available.

Users can search/dispaly/modify a record. The search key is the
license number.
Hmmm, no requirment or check that a driver's license number be
unique?
If there is a record with the license number matching
the specified key, the record is displayed and the user given the
option of modifying the record. A user can search for a record and
display it without performing any modifications.

Your program should perform the appropriate checks to ensure valid
input at ALL time.


As should any program. Validating input is very often a large
part of a program's code.

-Mike
Jul 22 '05 #6
titi wrote:
Question
Since your a newbie and this is to demonstrate simple C++,
I will show you how using advanced C++ techniques.
DO YOUR OWN HOMEWORK.

The road and traffic authority for a small country currently uses a
system to store information about all 'currently' licensed drivers.

A licensed driver has the following info stored about them in a
record;
The above sentence is a clue that some information will always
be represented together as a unit. In C++ we would place that
in a structure or class. Search the index of your text book
for "struct" and "class". Learn the differences between the
two.

1. Given name(s) of the license holder.(not more than 128 char (may
have spaces)).
In the above sentence, the keywords "name", "char" and "spaces"
indicates you are using a text variable. The "not more than 128
char" implies a maximum length of text. Your options are:
array of 128 chars.
pointer to a char
std::string.
I choose the std::string type since it is easy to use. Your
mileage may differ.

The above sentence is decribing a unit of information in the
structure, often called a "field".

2. Surname of the license holder.(Not more then 128 same like above).
The keyword "Surname" indicates a text variable. See above.

3. Driver license number.
Hmm, tricky. The "number" implies either an integer or a
floating point variable. Typically, driver license numbers
are unsigned integer. However, if the "numbers" contain
"-" (dashes), periods, or spaces, they may better be represented
as a text field. Your choice here.

I'll choice text which implies std::string.

4. The sex of the license holder.
Another field with possibilities. The sex or gender of
a person is either male or female. This can be represented
as:
bool (let male == true, female == false or vice-versa).
integer (ex. 1 == male, 2 == female).
char ('m' == male, 'f' = female)
enumeration (enum Gender {MALE, FEMALE};)
class; (search the web for "class" and "enumeration")
I'll choose enumeration: enum Gender {MALE, FEMALE};
5. The residental address of the license holder.(Not more then
128)same.
Addresses are ususally represented as text fields.
I'll choose std::string.

6. The registration number of the car the license holder drivers.(A
combination of char and numbers. The string must be six long.)
In requirements, the term "string" denotes a text field.
Here the requirement says that there must be 6 chars in each
field. One could interpret this as "at least 6", in which
a std::string could be used as long as the length is 6 or less.
In summary:
/* 4 */ enum Gender {MALE, FEMALE};
/* 6 */ const unsigned int MAX_REGISTRATION_LENGTH = 6;

class License_Info
{
/* 1 */ std::string given_name;
/* 2 */ std::string surname;
/* 3 */ std::string id; // identifier or number
/* 4 */ Gender sex;
/* 5 */ std::string resident_addr;
/* 6 */ std::string registration;
};

The numbers in C style comments refer to the requirement
number in the assignment.


The current system allow users to add new license holders, modify
details about prexisting license holders and remove a license holder
by entering the license number.
The above sentence lists the functionalities of the program:
add new license holder
modify existing license holder's information
remove a license holder

_You_ will have to create a user-interface (often called a menu)
to allow the user to select one of the above actions, and perhaps
an extra one to exit or stop the program.

Your job is to write a C++ program to replace the pre-existing system.
In doing so your program must;
This is not really clear given the requirements.
Were you given an existing program to modify?
Or are the next set of function to be added to your new program?
I would clarify this with the instructor or the one who handed
out the requirements. ALWAYS CLARIFY ANY AMBIGUITIES IN
REQUIRMENTS BEFORE CODING.

1.Allow user to add new license holders to the system.
2.Allow user to remove the license holder from the system.
3. Allow the users to search on a license number, display and
potentially modify a matched record.

The program is an interactive and menu driven. A user can choose from
a set of options to perform a particular action. It also to has
persistent storage.Each license holder has one record in the system.
Records a fixed lenght, therefore the C++ type string cannot be used
in the implementation.
Bummer, can't use std::string because of the restriction above.
Oh well, just use fixed length arrays of char.
The first time the program is run, there is no
data file in the file system. The file is a randoom access file used
to store a collection of records about liccense holders. The name of
this file is data.dat.

If the file already exists when the program starts, you are to read
the all records from the file, into array of records. You can assume
the maximum size of the array is 500. That is at any given time, your
system can hold a maximum of 500 license holders.

During runtime a user may add new license records.When a user adds a
new record, the program prompt the user to enter all details relevent
to the record. The record is inserted into the first available slot in
the array of records and written to the file immediately at the
correseponding record location. If there are no available records an
error is to be printed.

When a user removes a record, all elements of the record are cleared
and the record is marked as available. The corresponding record in the
file is then marked available.

Users can search/dispaly/modify a record. The search key is the
license number. If there is a record with the license number matching
the specified key, the record is displayed and the user given the
option of modifying the record. A user can search for a record and
display it without performing any modifications.

Your program should perform the appropriate checks to ensure valid
input at ALL time.


So, what is your issue with the assignment?
If there are any parts you don't understand, don't hesitate
clearifying them with your instructor. I have some instructors
where you need to get the clarifications in writing and notorized.
That way, when he/she changes his/her mind, you have proof.

Sorry, but I don't have the time now to write your program for
free. If you pay me, then I will write it for you.
My terms are $200.00 USD, payed in advance. Since you don't want
to write it, I'll assume you want me to deliver it too. So I
will need your instructor's email address and postal address to.
Many instructors require hard-copy in addition to an electronic
version.

Please let me know soon, as I have many current uses for the money.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Jul 22 '05 #7
Mike Wahler writes:
Hmm, I own four automobiles, and drive each at various times.
I wonder how that's supposed to be handled ? :-)
There are very few countries that have only 500 citizens. So might this be
for an imaginary country, perhaps????
Records a fixed [length], therefore the C++ type string cannot be used
in the implementation.

I see nothing in this specification that would prevent using the
std::string type to represent textual data.


I see *HUGE* problems in using a C++ string! You can not do random access
to a file with variable length records. That is *very clearly* the intent
of the problem!
Jul 22 '05 #8

"osmium" <r1********@comcast.net> wrote in message
news:c0*************@ID-179017.news.uni-berlin.de...
Mike Wahler writes:
Hmm, I own four automobiles, and drive each at various times.
I wonder how that's supposed to be handled ? :-)
There are very few countries that have only 500 citizens. So might this

be for an imaginary country, perhaps????
Records a fixed [length], therefore the C++ type string cannot be used
in the implementation.
I see nothing in this specification that would prevent using the
std::string type to represent textual data.


I see *HUGE* problems in using a C++ string!


I don't, unless a bit of thought is a 'huge problem' :-)
You can not do random access
to a file with variable length records.
Using std::string doesn't require variable length records.
That is *very clearly* the intent
of the problem!


const std::streamsize name_width(20);
std::string name("Mike");
std::fstream fs("filename");
fs << std::left << std::setw(name_width) << name;

You were saying? :-)

-Mike
P.S. Alternatively, if using fstream::read / fstream::write,
one can build the character buffer by e.g. << into a stringstream
and passing its 'str().c_str()' member, or sprintf() into the
buffer directly, using an appropriate length specifier in the
format string.
Jul 22 '05 #9
Mike Wahler writes:
"osmium" <r1********@comcast.net> wrote in message
news:c0*************@ID-179017.news.uni-berlin.de...
Mike Wahler writes:
Hmm, I own four automobiles, and drive each at various times.
I wonder how that's supposed to be handled ? :-)


There are very few countries that have only 500 citizens. So might this

be
for an imaginary country, perhaps????
> Records a fixed [length], therefore the C++ type string cannot be used > in the implementation.

I see nothing in this specification that would prevent using the
std::string type to represent textual data.


I see *HUGE* problems in using a C++ string!


I don't, unless a bit of thought is a 'huge problem' :-)
You can not do random access
to a file with variable length records.


Using std::string doesn't require variable length records.
That is *very clearly* the intent
of the problem!


const std::streamsize name_width(20);
std::string name("Mike");
std::fstream fs("filename");
fs << std::left << std::setw(name_width) << name;

You were saying? :-)

-Mike
P.S. Alternatively, if using fstream::read / fstream::write,
one can build the character buffer by e.g. << into a stringstream
and passing its 'str().c_str()' member, or sprintf() into the
buffer directly, using an appropriate length specifier in the
format string.


You obviously have a fondness for complexity that I do not share. Tools are
there to *help* you. If you have to apply a work-around, pick up another
tool instead of applying a patch.
Jul 22 '05 #10

"osmium" <r1********@comcast.net> wrote in message
news:c0*************@ID-179017.news.uni-berlin.de...
Mike Wahler writes:
"osmium" <r1********@comcast.net> wrote in message
news:c0*************@ID-179017.news.uni-berlin.de...
Mike Wahler writes:

> Hmm, I own four automobiles, and drive each at various times.
> I wonder how that's supposed to be handled ? :-)

There are very few countries that have only 500 citizens. So might
this
be
for an imaginary country, perhaps????

> > Records a fixed [length], therefore the C++ type string cannot be
used > > in the implementation.

> I see nothing in this specification that would prevent using the
> std::string type to represent textual data.

I see *HUGE* problems in using a C++ string!


I don't, unless a bit of thought is a 'huge problem' :-)
You can not do random access
to a file with variable length records.


Using std::string doesn't require variable length records.
That is *very clearly* the intent
of the problem!


const std::streamsize name_width(20);
std::string name("Mike");
std::fstream fs("filename");
fs << std::left << std::setw(name_width) << name;

You were saying? :-)

-Mike
P.S. Alternatively, if using fstream::read / fstream::write,
one can build the character buffer by e.g. << into a stringstream
and passing its 'str().c_str()' member, or sprintf() into the
buffer directly, using an appropriate length specifier in the
format string.


You obviously have a fondness for complexity that I do not share. Tools

are there to *help* you. If you have to apply a work-around, pick up another
tool instead of applying a patch.


I would not call it a 'patch'.

Exploit std::string's ease of use and robustness everywhere
in the code, apply a single 'setw()' manipulator for persistence
in a fixed-length-record file.

Mucking around with arrays when 'std::string' is so obviously superior,
is what I'd call a 'patch' in C++.

But I suppose we all have our own philosophies and opinions ...

-Mike
Jul 22 '05 #11
In article <c0*************@ID-179017.news.uni-berlin.de>, r124c4u102
@comcast.net says...

[ ... ]
I see *HUGE* problems in using a C++ string! You can not do random access
to a file with variable length records.
Nonsense!
That is *very clearly* the intent of the problem!


The original statement of the problem does specifically say that records
are to be of a fixed length, and "therefore the C++ string type can't be
used."

If student does succeed in getting somebody to solve his homework for
him, he will apparently have done his homework just as well as (if not
better than) the ignorant boob who's teaching this nonsense.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 22 '05 #12
"titi" <ww****@yahoo.com> wrote in message
news:bf**************************@posting.google.c om...
Question

The road and traffic authority for a small country currently uses a
system to store information about all 'currently' licensed drivers.

Your program should perform the appropriate checks to ensure valid
input at ALL time.


Everyone assumes this is a homework assignment. I'll give you the
benfit of the doubt and assume you have read the FAQ and would not ask
other to do your assignment for you.

I conclude that you have been hired by a very small impoverished
country which cannot afford an experienced programmer. Which country
are you working for? Be sure they pay you in advance!

Jonathan
Jul 22 '05 #13
ww****@yahoo.com (titi) writes:
Question


Where!?
--
Roger Leigh

Printing on GNU/Linux? http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 22 '05 #14
Jerry Coffin writes:

[Osmium writes:]
[ ... ]
I see *HUGE* problems in using a C++ string! You can not do random access to a file with variable length records.
Nonsense!
That is *very clearly* the intent of the problem!


The original statement of the problem does specifically say that records
are to be of a fixed length, and "therefore the C++ string type can't be
used."

If student does succeed in getting somebody to solve his homework for
him, he will apparently have done his homework just as well as (if not
better than) the ignorant boob who's teaching this nonsense.


I agree that the exercise could have been worded more elegantly. But how
many of us can write a perfect document of that length? You are not doing
the student any favor by making a post such as this. When there are two
sentences and then a blanket "nonsense" it is hard for a novice to figure
out exactly *what* is nonsense. You can not (or at the very least should
not) do random access to a file with variable length records. That is not
nonsense. And the exercise does explicitly state that it is a random access
file. (I hadn't really noted that when I made my earlier post, I deduced it
from the content.) I assume you knew what the instructor meant, why
purposely misunderstand him and then call him an ignorant boob, besides?

To the OP: the instructor does not mean that you can't converse with the
user via the C++ string, he means you should not save *that C++ string* to a
file. Or a C string either, for that matter. The records on the external
medium must be fixed length. Strictly speaking, he was not entitled to use
the word "therefore".

I would replace this:Records [are] fixed [length], therefore the C++ type string cannot be used
in the implementation


with this:
Records are fixed length on the external medium. Thus you should not
directly store variable length fields, such as C or C++ strings, in the
file.


Jul 22 '05 #15
"osmium" <r1********@comcast.net> wrote
You can not (or at the very least should not) do random access to a
file with variable length records.


Hogwash! Random access on variable-length records has existed since the early
days of computing, continues to this day, and is taught in the very first data
file management classes in any reputable university. All you need is an index
that gives you the start of the record and you can seek to it and retrieve it.

Here's a naively implemented snippet (without noisy error-checking):

int VRL::readRecord(const KEY_T & key, void * result, long maxLen)
{
long bytePos = getBytePos(key);

if (0 > bytePos) {
return -1;
}

fseek(m_f, bytePos, SEEK_SET);

long recLen;

fread(&recLen, sizeof(recLen), 1, m_f);

fread(result, min(recLen, maxLen), 1, m_f);

return 0;
}

Please don't assert that something is possible or impossible unless you
understand the field on which you're commenting.

Claudio Puviani
Jul 22 '05 #16
In article <c0*************@ID-179017.news.uni-berlin.de>, r124c4u102
@comcast.net says...

[ ... ]
I agree that the exercise could have been worded more elegantly. But how
many of us can write a perfect document of that length? You are not doing
the student any favor by making a post such as this. When there are two
sentences and then a blanket "nonsense" it is hard for a novice to figure
out exactly *what* is nonsense. You can not (or at the very least should
not) do random access to a file with variable length records.
This is what is nonsense -- you can, and many people DO use random
access on files with variable length records on an extremely regular
basis. Saying otherwise is nothing short of pure, unadulterated
nonsense.
That is not nonsense.
Repeating the same nonsense won't change it into something else. Look
at any decent database and you'll find that 1) it will support variable
length records, and 2) it will be able to do random access on those
records.

This isn't any sort of magic -- it's the simple result of a perfectly
normal thing called an index. It works pretty much the way an index in
a book does: you look something up in the index, and it tells you were
that data resides. You then do a seek directly to that point (i.e.
random access).
And the exercise does explicitly state that it is a random access
file. (I hadn't really noted that when I made my earlier post, I deduced it
from the content.) I assume you knew what the instructor meant, why
purposely misunderstand him and then call him an ignorant boob, besides?
Because somebody teaching a course in programming who doesn't know that
strings can be written as fixed-width fields and also doesn't know about
how to index a file is clearly ignorant should be restricted to teaching
small children how to tie their shoes, or some other subject of which he
has at least some grasp of the most basic facts.
with this:
Records are fixed length on the external medium. Thus you should not
directly store variable length fields, such as C or C++ strings, in the
file.


This is still pure nonsense. It still ignores the possibilities of
indexing and/or writing a string out in a fixed-width field. If you
want to say "variable-length records are beyond what we're covering
right now", so be it.

At least IMO, simplifying a problem to the point that it's approachable
is perfectly reasonable. Lying is a drastically different story.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 22 '05 #17
"Claudio Puviani" <pu*****@hotmail.com> wrote in message
news:79********************@news4.srv.hcvlny.cv.ne t...
"osmium" <r1********@comcast.net> wrote
You can not (or at the very least should not) do random access to a
file with variable length records.
Hogwash! Random access on variable-length records has existed since the

early days of computing, continues to this day, and is taught in the very first data file management classes in any reputable university. All you need is an index that gives you the start of the record and you can seek to it and retrieve it.
Here's a naively implemented snippet (without noisy error-checking):

int VRL::readRecord(const KEY_T & key, void * result, long maxLen)
{
long bytePos = getBytePos(key);

if (0 > bytePos) {
return -1;
}

fseek(m_f, bytePos, SEEK_SET);

long recLen;

fread(&recLen, sizeof(recLen), 1, m_f);

fread(result, min(recLen, maxLen), 1, m_f);

return 0;
}

Please don't assert that something is possible or impossible unless you
understand the field on which you're commenting.


Your reply seems a little harsh to me.

The general usage of the term "random access" for files usually means the
direct access of records, usually by relative record number. Since the
location of a logical record may include deblocking andcalculation of track,
sector location, it is done by having fixed length records and calculating
the track, sector location, reading the block, and locating the record
within the block.

The use of an index for each record in order to seek to the record's
starting location is not usually called "random access." Rather, it is an
indexed file.
Consider the early IBM implementations: BDAM (basic direct access method) is
a "random access" method. ISAM (Indexed sequential access method) uses the
indexed file technique.

It would be better to identify the fact that the use of "random access" has
unclear meaning and should be clarified by using some different term
depending on what was meant. I'd have said direct access, myself (any
program that randomly accesses records won't be all that useful, except
possibly for statistical applications).

Would you jump on me if I said arrays cannot be extended by adding elements
to them? (You can allocate a new, larger array, copy the elements to that
and it has been "extended." Followed by: "Please don't assert that something
is possible or impossible unless you understand the field on which you're
commenting.")
--
Gary
Jul 22 '05 #18
"Gary" <gl*******@comcast.net> wrote

"osmium"> You can not (or at the very least should not) do random access
"osmium"> to a file with variable length records.
"Claudio Puviani"> Hogwash!
"Gary> Your reply seems a little harsh to me."

I'm open to a more politically-correct adjective, but I stand by my statement.
The general usage of the term "random access" for files usually means the
direct access of records, usually by relative record number.
That's a seriously incomplete definition. The term "random access" describes the
ability to jump to any part of the file, as opposed to "sequential access" which
forces you to read through unrelated data before accessing what you need.
Whether the byte position or record number is derived from an absolute value, a
hash, an index lookup, or any other mechanism is completely irrelevant.
It would be better to identify the fact that the use of "random access" has
unclear meaning and should be clarified by using some different term
depending on what was meant. I'd have said direct access, myself
You're talking about two different things. "Direct/indirect access" and
"random/sequential access" are orthogonal concepts.
Would you jump on me if I said arrays cannot be extended by adding elements
to them? (You can allocate a new, larger array, copy the elements to that
and it has been "extended." Followed by: "Please don't assert that something
is possible or impossible unless you understand the field on which you're
commenting.")


That's quite the non sequitur. Ok, I'll play along. No I won't jump on you for
saying that "2+2=4"despite the fact that I jumped on someone for asserting that
the earth is flat.

Claudio Puviani
Jul 22 '05 #19

Claudio Puviani <pu*****@hotmail.com> wrote in message
news:4k********************@news4.srv.hcvlny.cv.ne t...
"Gary" <gl*******@comcast.net> wrote

"osmium"> You can not (or at the very least should not) do random access
"osmium"> to a file with variable length records.
"Claudio Puviani"> Hogwash!
"Gary> Your reply seems a little harsh to me."

I'm open to a more politically-correct adjective, but I stand by my statement.
The general usage of the term "random access" for files usually means the direct access of records, usually by relative record number.
That's a seriously incomplete definition. The term "random access"

describes the ability to jump to any part of the file, as opposed to "sequential access" which forces you to read through unrelated data before accessing what you need.
Whether the byte position or record number is derived from an absolute value, a hash, an index lookup, or any other mechanism is completely irrelevant.
It would be better to identify the fact that the use of "random access" has unclear meaning and should be clarified by using some different term
depending on what was meant. I'd have said direct access, myself
You're talking about two different things. "Direct/indirect access" and
"random/sequential access" are orthogonal concepts.

Claudio Puviani

If the instructor had meant the use of an index, the following would not
have made any sense:
When a user removes a record, all elements of the record are cleared
and the record is marked as available. The corresponding record in the
file is then marked available.


If he was talking about an indexed file he would simply have said "Remove
the entry from the index". This paragraph makes his intent crystal clear,
regardless of the fact that he may have used an imperfectly chosen word
here or there. The elements are munged to provide
privacy/security/whatever.

Jul 22 '05 #20
"osmium" <r1********@comcast.net> wrote
If the instructor had meant the use of an index, the following would not
have made any sense:
When a user removes a record, all elements of the record are cleared
and the record is marked as available. The corresponding record in the
file is then marked available.


If he was talking about an indexed file he would simply have said "Remove
the entry from the index". This paragraph makes his intent crystal clear,
regardless of the fact that he may have used an imperfectly chosen word
here or there. The elements are munged to provide
privacy/security/whatever.


Marking records as available is an ancient, if inefficient, technique and can
perfectly coexist with the use of index files. The index files and record files
are often managed separately, with the latter using free lists, markers (less
efficient) or other allocation mechanism. Whether the record is cleared or not
is, again, completely independent of how you deallocate the block.

If you don't have books on the subject, I suggest you have a look at Faircom's
on-line documentation: http://www.faircom.com/support/mans.shtml#ctpman, but
please stop making incorrect blanket statements. There's no shame in not knowing
something, but you look extremely bad when you impart incorrect information on
people who are trying to learn.

Claudio Puviani
Jul 22 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: the_proud_family | last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com I can't get the ball to go up right side and then I need it to turn around and keep turning until velocity=0 I have been at it for the ...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
15
by: Alfonso Morra | last post by:
Hi, I have some code from an example, that I want to retrofit into my project. The code from the example has the following line: SharedAppenderPtr myAppender( new...
1
by: Tito Brezovacki via .NET 247 | last post by:
Hi. The problem is very simple to describe, but tough to solve :( I have a printer that doesn't print on win98 using the usualprocedures (print() in C#) . I could barely get it to work on xpby...
4
by: Adrian | last post by:
This is off topic - however, I badly need to solve this problem. A program has been installed in Program Files of an W98 machine. Subsequently the program was removed from Program Files, not in...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
21
by: c | last post by:
Hi everybody. I'm working on converting a program wriiten on perl to C, and facing a problem with concatenate strings. Now here is a small program that descripe the problem, if you help me to...
8
by: Dhananjay | last post by:
hello everyone Do you have any information how to generate a tool using .net which is used to translate the web page contents to html format. Plz reply me asap Thanks in advance Dhananjay
8
by: SanjaiGandhi | last post by:
Hi ...i am new to programing....pls help to overcome this program.. The Program is..: if a = 557..using for loop or while or dowhile ..we have to get the answer for 5+5+7..that is what ever...
6
by: Kyote | last post by:
I'm trying to make, what I thought, would be a simple application. This application will help me organize files I have a lot of, on my computer(ebooks, pictures, etc..). I'm currently dealing with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.