Lab02 - Strings
Due:
Mon, Feb 7, 2022 at 11:59 PM
to Github Classroom Assignment
Requirements
- You will develop the C code and a
Makefilewhich builds one executable calledlab02(case sentitive) for the parts described below - You will use the
gradescript to test your results
Given
- You must clone my autograder repo and the test cases repo for this class into your home directory on the lab systems
- The
makeprogram is included on the lab systems so you do not have to install it - 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
- 80 pts: credible effort at source code and
Makefile - 90 pts: passes Part 1 test cases
- 100 pts: passes Part 1 and Part 2 test cases
- 101 pts: provide your own original implementation of
strstr()