Whoops! It was accidentally set to 11:59 instead of 23:59. I apologise for the confusion.
It is a good idea to keep the linked list functions
in a separate file, modeled on
list.c
,
but with a different name (for example, imglist.c
).
You will also need a corresponding "header" file
(for example, imglist.h
).
This header file can be modeled on list.h
,
but you will need to modify the struct
definition
so that, instead of just an int
,
it contains all the information needed for
each image (filename, dimension, quad tree, etc.)
The header files
quadtree.h
and
imglist.h
will both need to be
#include
'd
in imglist.c
and hw3.c
.
You might also like to move the following line from
hw3.c
to imglist.h
:
#define MAXLLENGTH 200
When an image is added, the command entered by the user
will consist of
the letter 'a'
, followed by a space,
followed by the filename. You will need to extract
the filename and copy it into the "filename" string
of your newly-created linked list node structure - either
character-by-character, or using a library function
like sscanf()
.
If you are copying code from list.c
to imglist.c
,
it is a good idea to only copy one or two functions
at a time, and modify them as needed.
For Stage 2 you will need versions of
makeNode()
, insert()
and
printList()
.
Remember that, whenever a new image is added,
it should be added at the "tail end" of the linked list.
First, change your Makefile so it compiles using
dcc
instead of gcc
.
When you run the program, it will
(hopefully) warn you when you have not allocated
space correctly, causing two arrays or structures to overlap
in memory.
If that doesn't help, try using gdb
, like this:
-g
option, e.g.
CFLAGS = -Wall -g
make
, type
gdb hw3then type
runand enter the input as normal. When the program crashes, it will tell you where it crashed, and allow you some other options.
If the node is NULL
then there is nothing to do.
If it is not NULL
,
then rotation can be achieved by:
ne
becomes nw
,
what was se
becomes ne
,sw
becomes se
,
what was nw
becomes sw
.