Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ program to print all possible substrings of a given string

// C++ program to print all possible
// substrings of a given string
 
#include<bits/stdc++.h>
using namespace std;
 
// Function to print all sub strings
void subString(char str[], int n)
{
    // Pick starting point
    for (int len = 1; len <= n; len++)
    {   
        // Pick ending point
        for (int i = 0; i <= n - len; i++)
        {
            //  Print characters from current
            // starting point to current ending
            // point. 
            int j = i + len - 1;           
            for (int k = i; k <= j; k++)
                cout << str[k];
             
            cout << endl;
        }
    }
}
 
// Driver program to test above function
int main()
{
    char str[] = "abc";
    subString(str, strlen(str));
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: len in cpp 
Cpp :: c++ - 
Cpp :: Converting Strings to Numbers in C/C++ 
Cpp :: c++ awitch statements 
Cpp :: cpp vector popback 
Cpp :: __builtin_popcount long long 
Cpp :: C++ vector at() method 
Cpp :: string copy in cpp 
Cpp :: sum of n natural numbers 
Cpp :: transpose matrix c++ vectors 
Cpp :: how to sort string array in c++ 
Cpp :: tower of hanoi 
Cpp :: nth fibonacci number 
Cpp :: find second largest number in array c++ 
Cpp :: gcd in cpp 
Cpp :: unordered_map in c++ 
Cpp :: how togreper 
Cpp :: lcm in c++ 
Cpp :: c++ tuple push_back 
Cpp :: c++ profiling tools 
Cpp :: how to find second smallest element in an array using single loop 
Cpp :: whatsup 
Cpp :: cpp split bits 
Cpp :: cpp module 42 
Cpp :: c++ dynamic array 
Cpp :: ternary operator rsut 
Cpp :: delete item from linked list in c++ 
Cpp :: how to block the screen c++ 
Cpp :: can you add a bool and an int 
Cpp :: punteros a arrays 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =