cp40710 - at the end of the string do not need to be...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 3331 COMPUTER PROBLEM 4 Spring 2007 (due 5pm 4/3/07) Write a C program that will read a string of characters consisting of alphanumeric characters, blanks, and punctuation symbols. The program is to "code" the string, in a format described below, and then print the string and its code on one line. For each letter in the string, the program is to determine a code which will be the position of the letter in the alphabet—whether the letter is upper or lower case. That is, both 'a' and 'A' will have a code of 1, both 'z' and 'Z' will have a code of 26, etc. Blanks and punctuation symbols are to be printed as they are (that is, not translated into codes or numbers). A digit in the string is to be converted to an uppercase letter, where the letter is the one whose position in the alphabet is equal to the digit (1 corresponds to A, 9 corresponds to I, etc with 0 corresponding to J). Consecutive blanks are to be replaced by a single blank in the output, except when the blanks are in front of a punctuation mark, in which case all of these blanks must be removed. Blanks
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: at the end of the string do not need to be detected/codedassume the string ends with the last non-white space character. The program is to print the input character string on the right hand side of the output line and the code of the string on the left hand side of the output line, with three spaces between the two. The coded characters in the coded string should be separated by vertical lines. For example, if the input string is This is March 7 , 2007. the output should be |20|8|9|19| |9|19| |13|1|18|3|8| |G|,| |B|J|J|G|.| This is March 7 , 2007. The input file, cleverly named cp40710.txt, will have several strings, one string per line. No string will contain more than 50 characters. Your program should process all of the strings, writing the output to a file named cp40710.out. Your program must include a function whose prototype is void encode(char instring[ ], char outstring[ ]); No global variables are allowed....
View Full Document

Ask a homework question - tutors are online