Lab02 - Strings

Due: Mon, Feb 7, 2022 at 11:59 PM to Github Classroom Assignment

Requirements

  1. You will develop the C code and a Makefile which builds one executable called lab02 (case sentitive) for the parts described below
  2. You will use the grade script to test your results

Given

  1. You must clone my autograder repo and the test cases repo for this class into your home directory on the lab systems
  2. The make program is included on the lab systems so you do not have to install it
  3. Lecture material will cover necessary C concepts, as well as Makefiles and usage of the autograder.

Part 1

Count the occurrences of a single character in a string. Example output:

$ ./lab02 foobar o
2
$ ./lab02 foobar
invalid arguments

Part 2

Count the occurrences of an N-character string in another string. Example output:

$ ./lab02 abbabb bb
2
$ ./lab02 abbabb bc
0

You may use the C library function strstr() if you wish. char *strstr(char *a, char *b) returns a pointer to the first occurrence of b if b occurs in a, or NULL if b does not occur in a

Rubric

  1. 80 pts: credible effort at source code and Makefile
  2. 90 pts: passes Part 1 test cases
  3. 100 pts: passes Part 1 and Part 2 test cases
  4. 101 pts: provide your own original implementation of strstr()