We will consider the words numbered as:
word0 word1 word2 ...
where words are sequences of characters separated by spaces.
For example, we could run the program:
ee150:wiliki:45> word
this is a longer string
and the output would be:
this a string
is longer
This is an example of a program where we need to use
and array, because we must make two passes over the characters
in the string.
The first time we print the even words, the second time we print
the odd words.
get a string
print the even words
print a newline
print the odd words
print a newline
We will implement each of these steps as a function, so
we could write the code right now for main in
word.c
with a macro defined in
word.h.
We therefore need two functions, print_even() and print_odd. We know what they must do. Their prototypes are in evenodd.h.
We can build this program using the makefile.