question archive Exercise 4

Exercise 4

Subject:Computer SciencePrice: Bought3

Exercise 4.31.29: In this exercise, you will manipulate C character strings, which are simply arrays of characters that are terminated by the ASCII NULL character (0x00, ’\0’). (countsubsstdin.c) This program reads two mandatory and one optional inputs from standard input, each on a separate line, until EOF. Each of the two required inputs is a string. The second string will be searched for occurrences of the first string as a substring. The number of occurrences found will then be displayed to standard output. The presence of the optional third input -nooverlap informs the program that the substrings identified may not overlap. If an incorrect number of inputs is provided, or if the optional third inputprovided is anything other than -nooverlap, an appropriate usage message must be printed to standard error and the program must halt with exit status 1. If the first argument is the empty string (i.e., a string having length 0), print an error message to standard error and the program must halt with exit status 1. Store these input strings on the heap (not the stack) so they can be of an arbitrary size. The following are some sample, non-exhaustive test cases. Your program is expected to produce identical output. Do not prompt for input.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE