The algorithm cannot be taken for granted. Do not use a special case to explain how fast the algorithm is, but analyze its worst case.
This is the overall efficiency of the algorithm.
You are only a special case
What do you do if the main string is 266 characters? And the substring has only 4 characters. Have you ever wondered how much space you have to waste?
Let's learn about dynamic memory allocation