I am stuck at this normalization part. I am using a string and reading data one by one. I keep getting blank. The program compiles. Any hints to what to do next would be awesome. How would I complete the 5 steps below? Steps 3 and 4 work fine.
A program that reads a text file using character-by-character I/O and performs the following normalization tasks:
1. Replaces all tab characters with 8 spaces
2. Replaces all upper-case letters with lower-case letters
3. All @ symbols will be replaced by the word "at".
4. All = signs will be replaced by a series of 19 = signs.
5. When you find an asterisk, you will print a series of asterisks. The character following the asterisk indicates the number of asterisks to print. Use the ASCII value of the character following. Number of asterisks is ASCII value minus 32 plus 1. The character following the asterisk is used only as a counter, not a data character.
You are reading in a string at a time. You really want to read in a character at a time. If the input is
myName@myURL
, the output should be
myNameatmyURL
, but if you read in a string at a time (lines 39 - 40), you will never find the '@' in the middle of the word. And since you don't want to ignore white space, don't use ">>", but use get() instead. (http://www.cplusplus.com/reference/istream/istream/get/)
After you read in characters rather than strings, your calls to isupper and tolower should work. Note that tolower will return its argument unchanged if it is not an uppercase letter, so it is not expressly necessary to call isupper if you format arrange your if / else if / else statements correctly.
After you read a '*' you need to read another character. The character can be used as an integer value, so use that value to print out a series of '*' So, if you read in
*!
, you should print out
**
because the ascii value of '!' is 33 (33 - 32 + 1 = 2).