I want to implement in C/C++ function that its input is an array of chars like char string[]="010101010001110001110001110001110001110001110001 11000111000111000111000111000111000111" and to search on specific string pattern, then the function returns an array of chars or string (same concept) according to last index of my searched pattern + 6 steps, for example according to the same input that I attached above, lets assume I want to search on string pattern '01010101' , so if the search pattern found in my input *if it's found *, return the string that its index in my input is : last index of my searched pattern in my input + 15 => return the string that starts from last index of my searched pattern in my input and ends last index of my searched pattern in my input + 6 , in my example it should return : returns the extraction of required string in another char array[]: "000111" why? because I searched for '01010101' and the last index of this in my input is at index=7 ,so the returned string starts from index=8, and I add +6 to my index=7 so it ends at 7+6 =13 , so the returned string (extracted string from my input) will be from index =8 till index=13, so the returned array of chars in my example is: "000111" for more clarification, the searched string pattern in my input is "01010101" , if not found then return null .. , if found (like my example ) then I take the last index in my input array of my searched pattern that in my example last index is at index=7, so my returned string will start at index=8 of my input string , and will be longed till (last index of my searched pattern=7 ) + 6 steps through my input string so at index =13 my returned string(required string) will end.
so the output of my example is : "000111".

if the searched pattern not found, then return NULL or Enum type EROR.

Any help please how can I do that in C/C++ ? thanks alot for any help!!