CptS 122 –
Data Structures
Programming
Assignment 2: Fun with Arrays,
Strings, and Pointers (Continued)
Assigned:
Due:
I.
Learner
Objectives:
At
the conclusion
of this programming assignment, participants should be able to:
II.
Prerequisites:
Before
starting
this programming assignment, participants should be able to:
For
each of the
following problems create a separate Microsoft VS 2008 project. Within
each
project you must have at least one header file (.h) and two source
files (.c).
Before you turn in this assignment, be sure to place each project
folder into a
single <your last name>_pa2 folder.
1. Write a C program that merges two strings such that the words in the final string are in sorted order. The original two strings will not necessarily have their words in sorted order to begin with. For example, your starting strings could be “it is raining” and “computer science lab”. The merged version in this case would be “computer is it lab raining science”. As an even simpler example, consider the starting strings “cat apple” and “dog avocado”. The merged version in this case would be “apple avocado cat dog”. You will need to merge the two strings into a third, dynamically allocated array.
2. Write a C program which reads characters from a file and determines the number of each character, and the line of which each one is found, in the file. Assume the file consists of alphabetic characters only. You may NOT use if statements to “count” each character. For example, if the file contents are:
This is a file
It has 3 lines
This is the third
Then the output should be something like the following:
t – occurs 5 times in the file, on lines 1, 2, and 3
IV. Submitting Assignments:
V. Grading Guidelines:
This
assignment is
worth 100 points. Your assignment will be evaluated based on a
successful
compilation and adherence to the program requirements. We will grade
according
to the following criteria: