CS1101C Practical Exam

Question 5 (xxxx - xxxx hours)

Handphone Multitap

The name of your C program file must be called multitap.c, files with any other name will not be marked.

The deadline for this lab is Wednesday 12 November 2008, xx:xx:xx hours. Strictly no submissions will be accepted after the deadline.

Introduction

In the days before the advent of T9 "Text on 9 Keys", one has to rely on multi-tap functionality to send text messages with a handphone (or cellphone). Each alphabet character is assigned to a number from 1 to 9 as shown on the right. Space is assigned to the number 0. On the top of each button (from 2 to 9), is a sequence of alphabets. For example, the button 2 has ABC specified. So in order to key in A, we press 2 once; to key in B and C we press 22 and 222 respectively.

Your task is to read a series of text messages from an input file and display them as multi-taps. A skeleton file multitap_skel.c is given to you (it has been copied into your directory by the “pesetup” command). You may either modify it, or write a completely new program. A sample input file messages.txt (it has been copied into your directory by the “pesetup” command) containing 12 messages is also provided and is reproduced below.

I AM LATE
IN A MEETING
CALL YOU LATER
BUSY RIGHT NOW
CALL ME LATER
MEETING IS CANCELLED
SEE YOU
PLEASE CALL ME
I LOVE YOU TOO
HAPPY BIRTHDAY
THANK YOU
WAITING FOR CAB

The output of your program for the above file is as follows:

44402605552833
44466020633.338444664
222.2555.55509996668805552833777
228877779990777444.4.448066.6669
222.2555.555063305552833777
633.338444664044477770222.26622233555.55533.3
777733.33099966688
75553327777330222.2555.5550633
44405556668883309996668808666.666
4427.799902244477784432999
84426655099966688
92444844466403336667770222.2.22

Take note of the following.

Important Notes

Do not use any structures or any form of dynamic memory allocation (using malloc or calloc) in your program, else no credit will be given.

Remember to submit your program frequently using the submit multitap.c command, and check your submission using the check command.

All the best!

UNIX commands

Some useful UNIX commands (in case you forgot what you did in Lab 0):

  1. dir”: lists all the files in the directory.
  2. cp a.txt b.txt”: copies a.txt to b.txt.
  3. mv a.txt b.txt”: moves / renames a.txt to b.txt.
  4. cat a.txt”: shows the contents of a.txt.