[Solved] C++ simple syntax


npos indicates the end of the string (you can think of it as being the index version of end ()). pos is the position of the search string found in the searched string. It gets incremented in every iteration so that it searches for a new occurrence each time. size_t is an unsigned integer type suitable for expressing the sizes of objects in memory.

In this implementation overlapping occurrences get counted, e.g.

Counting “aaa” in “xaaaay” will count 2 occurrences.

solved C++ simple syntax