CS
2500 Spring 2011
Lab 5
Pointer-Based Implementation of a Linked List
We want to
better understand how to use pointers in C++ and linked lists. The
section of our text that covers this starts on page 205. Your task is
to write two programs:
1. Create a linked list to store integer values.
- Store the values 0,
1, 2, 3, 4 in order in the list
- Delete the node with
0
- Delete the node with
3
- Insert 6 at the end
of the list
- Insert 5 into the
list (preserving order)
- Write the resulting
list to a file called "numbers.txt"
2. Write a program that opens the file "numbers.txt", creates a
pointer-based linked list and places the integers into the node items
in order. After you close the input file, use a for loop to print out
the values in the list.
3. Your script should include:
g++ listToFile.cpp
a.out
more numbers.txt
q
g++ fileToList.cpp
a.out
What to Submit
Name your files:
listToFile.cpp
fileToList.cpp
script_lab5
Turn in your programs
and script to the CS Homework Submission System at https://hopper.csustan.edu/cshomework/
Choose instructor: cs2500mm
Choose course: CS2500
Choose assignment: Lab5