logo CodeStepByStep logo

match_at_offset

Author: Cynthia Lee (on 2016/10/05)

Write a function named match_at_offset that accepts two strings left_frag and right_frag (as char*) and one integer offset as parameters and determines if the right string matches the left when placed starting at left_frag[offset], so that the right extends past the end of the left. In other words, this function tests if the left string and right string are equal to each other starting at left_frag[offset] and right_frag[0], and ending at the end of left_frag or right_frag (whichever ends first).

Returns true if there is a match, else false.

Also returns false in the case that offset is <= 0, or when the match does not involve right_frag extending past the end of left_frag.

For example, the call match_at_offset("hello", "lol", 3) returns true.

The function's header should be:
bool match_at_offset(char *left_frag, char *right_frag, int offset)

Type your solution here:


This is a function problem. Write a C function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.