Count of sub | C ++ implementation of the approach ; Function to return the count of possible sub - strings of length n ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countSubStr ( string str , int n ) { int len = str . length ( ) ; return ( len - n + 1 ) ; } int main ( ) { string str = " geeksforgeeks " ; int n = 5 ; cout << countSubStr ( str , n ) ; return 0 ; }