classifieds
directory you are asked to create.
hello.c
program.
ads
'' directory
currently exist and what files are in those subdirectories.
For this homework, you will extend the functionality of the scripts
you created for Homework 1, so that a user on the Web can post new
advertisements to the system.
When the user selects the ``POST''
option from the main classifieds menu, a form that looks like
this should be displayed. (Ask your Web browser to save the HTML source
of this form to a file for your own use.)
This form asks the user to enter various kinds of identification and
billing information, as well as the text of the article to be posted.
When the user clicks on ``SUBMIT
'', a confirmation form that
looks like
this should be displayed.
If the user clicks on ``OK
'', then the ad should be posted,
and an entry should be made in a billing log, as described in more detail
below. Then an acknowledgement screen that looks like
this should be displayed.
Before accepting an ad to be posted, your scripts should verify that the user has in fact filled in something in the identification and billing fields, and has actually entered some text for the ad. If the user has not done this, then you should display an appropriate error screen, rather than the acknowledgement screen.
Once an ad is accepted, your scripts will post the ad by placing the
text of the ad into a file in the subdirectory of the ``ads
''
directory that corresponds to the category selected by the user.
The only real issue here is how to select a unique filename for the new
ad, so that there is no conflict with the filenames of any existing ads.
One way to do this is to maintain a special file in each subdirectory in
which ads are stored. This file could be given a name like
``.NEXT
'' which starts with a dot so that it won't normally
be visible using ls
. This file should have as its contents
the ASCII text representation of the next available sequence number to
be used as the name of an ad. Thus, when you first create a subdirectory,
such as "Real Estate Rentals", you would create the file .NEXT
with contents, ``1
.'' The first ad inserted in the directory
would be placed in a file named ``1
'', and then the value
stored in the .NEXT
file would be changed to ``2
.''
Your scripts should also take care of computing the amount that should
be billed to a person posting an ad. Your billing should be computed
at a rate of $1 per word. You can use the ``wc
'' command
to count words in a file. The amount of money that will be billed for
an ad should be displayed to the user on the confirmation screen, before
actually posting the ad. When the ad is finally posted, you should
log the billing information to a file .BILLING
in the
``ads
'' directory. This file should contain one line for
each article posted, and it should have the format shown
here.
Each line corresponds to one posting of transaction, and it consists
of eight TAB-separated fields containing the following items of information:
date
command.
VISA
,
AMEX
or MC
.
After writing and testing your scripts, submit electronically the entire
contents of your classifieds
directory as in Homework 1.
hello.c
:
a.out
will be produced. Run this executable by typing a.out
.
You should see the Hello world
message printed on your
screen.
hello
instead of the default
executable a.out
. The command:
hello.c
is printed on the standard output. Redirect this output to a file
hello.cpp
and have a look at it. Basically, what has taken
place is the system header file stdio.h
has been inserted in
place of the #include
. The command:
hello.o
instead
of an executable binary file. Relocatable object files are linked
together by the link editor to build executables from several
separately compiled source files. The command:
hello.c
into an assembly language program
hello.s
. Have a look a the file hello.s
,
so you recognize what it looks like. The command:
hello.c
with an expanded symbol table that
can be used by the gdb
debugger. In general, if
you intend to do debugging, you should compile your programs
with this option.
hello.c
by introducing
an integer variable i
and a while
loop,
so that it prints the greeting 10 times instead of just once.
hello.c
, together with the
files hello.o
, hello
, hello.s
,
and hello.cpp
generated above.