CS 2213 Advanced Programming Third Midterm Exam Practice Problems: Spring 2001
- Write a filter that outputs only lines shorter than a given length.
The length is given as a command line parameter.
Hint 1: Use atoi to convert the command line parameter to an
int.
Hint 2: This can be done with exactly one malloc.
- Write a filter that outputs only lines longer than a given length.
The length is given as a command line parameter.
Hint: The solution is similar to problem 1.
- Write a filter, atod, that converts its input to strings
the ASCII code for each character, one per line.
For example, if the input contains one line with the characters abc,
the output will be:
96
97
98
10
- Write a filter, dtoa, that converts the output from atod
back to its original form.
- Write the function
insertafter(nodeentry *nodep, stringval sval)
Which inserts sval into the double linked list, q
after the node pointed to by nodep. You may assume that
nodep points to a node in the list.

typedef struct stringval {
char *str;
int val;
} stringval;
typedef struct nodeentry {
stringval sval;
struct nodeentry *tofront;
struct nodeentry *torear;
} nodeentry;
typedef struct {
nodeentry *front;
nodeentry *rear;
} queue;
static queue q = {NULL,NULL};