logo CodeStepByStep logo

match_at_offset

Related Links:
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)

Function: Write a C function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.