Pracs 0(A and B), CSE2304, CSSE, Monash, Semester 1, 2004

The [on-line] versions of the prac's may include [links], corrections and supplementary material and are to be taken as the reference documents. Check the on-line material regularly.

Candidate: You must prepare your solution to this programming exercise in advance (a 6pt subject => 12-hours work per week, every week). The designated platform, on which your solution must be demonstrated and on which it will be marked, is the `gcc' compiler running on `Linux'. If you develop a solution on another platform, it is your responsibility to ensure that it works correctly on the designated platform. Read the information under the [prac' guide], [on C and code modularity], [missed pracs] and [plagiarism] links on the [home page]. It is better to have a program that does only part of the prac' but compiles and runs rather than to have a more complex program that crashes or, even worse, does not compile. So keep copies of old working partial solutions.

Prac's are marked on the performance of your program and also on your understanding of the program. I.e. Perfect program with zero understanding => zero marks! ``Forgetting'' is not an acceptable explanation for lack of understanding. Unless otherwise noted, you must write all the code yourself, and may not use any external library routines, the usual I/O (e.g. printf) and mathematical (e.g. log) routines excepted.

NB. Remember that, from prac1, each week's prac' groups are set their own specific problems. Make sure that you do the correct problem for your prac'! You will get zero marks if you solve the wrong problem. The exam, and the prac' work, are both hurdles (half-marks) for the subject. If you fail one, or the other, or both, the highest mark that you can get for the subject is 44%(N).

Demonstrators are not obliged to mark programs that do not compile or that crash. Time allowing, they will try to help in tracking down errors, but they are not required to mark programs in such a state, particularly those that do not compile. Therefore keep backup copies of working partial-solutions (also see above).

Objectives: Preparing prac' work in advance, familiarity with Linux, files & directories, using a text editor & gcc, command-line processing, and using existing Linux resources.

Prac 0 (A & B), week 2, 8-12 March 2004

If you are not familar with the Unix system, then in order to complete this prac you need to visit the Online Unix Prac System and complete all the topics in the set called ``CSE2303/CSE2304 Prac0: Introduction to Unix''. On the other hand, if you are familar with the system, then proceed straight to the exercises below.

Online Unix Prac System (optional if you know Linux/ Unix).

Logging In: If you have an AuthCate password and you can remember it, then visit:
and enter your AuthCate username and password.

Click on the ``Edit Sets'' link, and choose the set called ``CSE2303/CSE2304 Prac 0: Introduction to Unix''. You can additionally choose the optional topic set if you want some extra practice with Unix. Click on ``Change Sets'', and you will see a list of topics.

Now, just go through each of the topics one by one, and do what they say. The Unix Prac System remembers which topics you have completed, so when you come back to it later it will remind you which topics you've already done.

Guest Login: If you have forgotten or never received your AuthCate password, you can still use the Unix Prac system, but it will not remember which topics you've done, nor will it present the topics in a logical order. The URL is:


You must write a program to process a collection of words; the program has a command line parameter [e.g.(click here)] and [here]. Then your program must be used with other useful Linux/Unix commands to perform a more complex task.

  1. Write a C program, prefer, with a command-line parameter goodString. The parameter goodString is a string of "good" letters.
    The program must read from standard-input, and must print each word to standard-output preceded by (i) the number of its letters from goodString, and (ii) the word's length.
    E.g. If you run
    prefer aeiou
    i.e. goodString is aeiou
    and then you type the input
    Little Miss Muffet sat on her tuffet,
    eating her curds and whey.
    the program must output:
    2 6 Little
    1 4 Miss
    2 6 Muffet
    1 3 sat
    1 2 on
    Here a word is a string of upper and/or lower-case letters. Case is irrelevant in goodString, i.e. `i' must also match `I'.
  2. Unix/Linux systems provide a dictionary of English words. To find this dictionary, you might find the Unix commands locate, less, ls, etc. helpful. The dictionary is often found in a directory called dict in a file named words.
    Find the dictionary and run your program prefer using the dictionary as the input.
    To find out about locate, try:   man locate
    and you should also try the following, of course:   man man
    Use input - output redirection, < and/or >, to run your program on the dictionary.

  3. Use your program prefer in conjunction with other Unix commands to make a "pipe statement", i.e.  cmd1 | cmd2 | ..., which takes as input the dictionary you found above and a parameter goodString, and prints out those words of length 6, with the ones having most "good" letters first. For example, using the input and command-line parameter in question 1, the corresponding output should be:
    3 6 eating 
    2 6 Little 
    2 6 Muffet 
    About pipes [here].
    You might find the Unix commands man, sort, grep, etc. useful. 
    Change the pipe statement you used above to find a 9-letter word in the dictionary that has as many vowels as possible.

Marking   n.a.

© 2004 L. Allison & D. Albrecht, School of Computer Science and Software Engineering, Monash University, Australia 3800.
Created with "vi (Linux & IRIX)",   charset=iso-8859-1