Case studies over structure types and strings . Instructor – Gokcen Cilingir Cpt S 121 (July 21, 2011) Washington State University. Problem 1.
Instructor – GokcenCilingir
Cpt S 121 (July 21, 2011)
Washington State University
Problem statement: Write a program that reads a paragraph from a text file and produces the list of words read from the file in the order of last word first. Output should be written to both standard output and to a file.
intreadWord(FILE * infile, char *word) – takes string formatted input from a file and places it into the given string.
void readWordList(FILE * infile, char wordList[MAX_WORD_LENGTH], int *size) – repetitively takes string formatted input from a file (until EOF) and places them into the given string array. Returns as output parameter the size of the list.
void customPrint (char *str, FILE * outfile) – writes the given string both to standard output and to the given file.
Problem statement: Extend the program you’ve written for problem 1 such that each word is displayed stating it’s length. For example, if the word is “Write”, than “Write (5)” should be displayed.
Problem statement: Extend the program you’ve written for problem 2 such that each word is right-stripped from punctuation.
Additional function to write:
void rightStripFromPunctuation(char *str) – Alters the given string such that it is stripped from preceding punctuation
Problem statement: Write a program that takes nouns and forms their plurals on the basis of these rules:
a. If noun ends in “y” remove the “y” and add “ies”
b. If noun ends in “s” , “ch”, or “sh”, add “es”
c. In all other cases, just add “s”
Print each noun and its plural. Try the following data:
chair dairy boss circus fly dog church clue dish
Problem statement: Numeric addresses for computers on the international network internet are composed of four parts ,separated by periods of the form
where xx, yy, zz, and mm are positive integers. Locally, computers are usually known by a nickname as well.
The program should display a list of messages identifying each pair of computers from the same locality-that is , each pair of computers with matching values in the first two components of the address. In the messages, the computers should be identified by their nicknames.