Introduction
,,,,
typedef struct {
Uint id; // the unique id of the note
// time_t is defined in time.h, which usually is an integer representing the number of seconds since the Epoch.
time_t time; // the last time that the note is created or updated
Boolean encrypted; // when TRUE, it is encrypted; False; not encrypted
} NoteInfo;
typedef struct note{
NoteInfo info;
String tags; // each tag is wrapped in a pair of square brackets [tagName], for example [math][history][chinese]
String string; // A String object, containing the address of the first character of the string, and the size of the string
}Note;
Requirement
LP102 2017 Spring
Homework 1
Notes and Files
∗
Zhiyao Liang
MUST FIT
Sunday 15 May 2017
Abstract
In this homework, we will practice structure, linked list, and file op-
erations. We want to make a program that works like a notebook, with
convenient and safety features. Using it, we can easily add, save, view,
encrypt/decrypt, and search notes. The file is protected by password.
1 Tasks
Read and understand the provided code and comments.
∗ The picture is found from the Internet.
1
The behavior. of the program can ge roughly described as follows. Notes
are stored in memory in a double-linked list. When a file of notes is opened,
all of its notes and related information are loaded into memory. Notes are
recorded in some double-linked list in memory. Any update to the note
list will immediately synchronized (saved) to the file. For example, when-
ever a note is added, deleted, encrypted/decrypted, these changes will be
immediately saved to the file.
Try the provided sample executive files are generated by compiling the
files on Windows, Mac OS X, and Unbuntu Linux using gcc. Try all of the
operations to see how the program runs. The provided .bat and makefile
files indicates how to compile the program using command line.
What you need to provide is listed below:
• Provide the code of the missing functions, which are clearly marked
by the comments in the .c files asking you to provide the missing code.
You can also add any code (like some extra function) that you want.
• Bonus 1: up to 15 points. Add some interesting or useful feature to
the program. You can also change the user interface. For example,
when a user wants to decrypt a note, after showing the decrypted
message to the user, the program will ask if the user want to save the
change to file. Only when user answers y will the change be saved to
file. Another example, for added security, when password is saved in
file, it is always encrypted, and when it is loaded into memory, it is
decrypted.
• Bonus 2: up to 5 points. Use the program to record some interesting
or useful notes in a file. Doing this can show that you have tried the
program and understand its operations. You can name the file like
LiShan_cl_win.nt , if your name is Li Shan, and you run the program
compiled using cl on Windows. Send this file together with the other
code files in a email.
The provided comments and the discussions in classroom should be
enough for explanation of the homework. Compile and run your programs.
2 Submission
• Due time: Saturday 03 June 2017, 10:00pm.
• Compile and debug and run your program.
2
• Your code should be pretty, i.e, you should indent and align your lines
and code nicely and logically following some pretty-printing style.
• At the top of each of your source file, write your name, student id and
date as comments.
• Attach the finished .c and .h to an email. Do not attach binary files
(.o, .obj, .exe or executable) files, since doing so will make your email
being considered as virus by the Gmail system.
• Send your email to
• The title of your program should be like:
[name][student id][D1|D2][hmk Notes]