Back to DFS's C Page


OAC Problem Set III

Strings, Functions & Pointers Problem

For this problem, you are to use the functions which you wrote for Problem Set II: Length(), Pos(), Delete(), Insert() and Copy().

Include all of the following features in a single program.

  1. The string "I love the Buffalo Bill legend." is stored in the variable CurrStr, which is local to main().
  2. The user is allowed to change the string by insertion, deletion, replacement, upcasing.
  3. The user is allowed to get the following information printed out: length of the whole string, location of a sub-string.
  4. A one-line menu is presented to the user each time after the CurrStr is printed.
  5. Bulletproofing.

Your program will have the following structure. You are to turn in a completed hierarchical structure diagram for your program. Include parameter information in your diagram.

                          main
                            |
              ----------------------
              |                    |
          initialize              menu
                                   |
    -----------------------------------------------------------------
    |            |             |            |          |            |
deletestring insertstring replacestring findstring upcasestring lenstring
                 |
            GetValidInteger

The following will be your example run -- inputs are given in red. N.B. ^ indicates a space in the input.

Current Str: I love the Buffalo Bill legend.
             0123456789012345678901234567890
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: f
Find what string? Bill
Bill was found at position 19.

Current Str: I love the Buffalo Bill legend.
             0123456789012345678901234567890
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: R
Replace what string? I
With what string? We

Current Str: We love the Buffalo Bill legend.
             01234567890123456789012345678901
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: i
Insert what string? all^
Where? 3

Current Str: We all love the Buffalo Bill legend.
             012345678901234567890123456789012345
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: u
Upcase what string? Buffalo

Current Str: We all love the BUFFALO Bill legend.
             012345678901234567890123456789012345
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: i
Insert what string? Doug Flutie,^
Where? 12

Current Str: We all love Doug Flutie, the BUFFALO Bill legend.
             0123456789012345678901234567890123456789012345678
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: D
Delete what string? ^legend

Current Str: We all love Doug Flutie, the BUFFALO Bill.
             012345678901234567890123456789012345678901
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: L
The current string is 42 characters long.

Current Str: We all love Doug Flutie, the BUFFALO Bill.
             012345678901234567890123456789012345678901
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: I
Insert what string? ^quarterback
Where? 41

Current Str: We all love Doug Flutie, the BUFFALO Bill quarterback.
             012345678901234567890123456789012345678901234567890123
Enter (D)elete, (I)nsert, (R)eplace, (U)pcase, (F)ind, (L)ength, (Q)uit: q

© DFStermole 2001
Created 1 Dec 01
Last Modified 7 Dec 01