Homework 22

Write a program that reads a target string (targetString) and a test string (testString) and tells the user whether targetString is a substring of testString.  targetString is a substring of testString means that targetString appears (in order and together!) somewhere in testString. For example: low is a substring of allowable (see it? "allowable"), but not of withhold (the letters are there, but not in order in "withhold"), nor in landowner (the letters are there and in order but not together in "landowner").


A typical run of your program should look like this:

Enter target string: act

Enter test string  : reactionary


The target act IS a substring of the test string reactionary!



Turn in

  1. A handrawn picture of the string “act” and the string “reactionary” represented as arrays of characters, complete with array indices.
  2. A printout of your program, along with a screen capture showing it run on the above example.