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 :: windows servis from console app 
Cpp :: ++m in c 
Cpp :: c++ stack 
Cpp :: how to signify esc key in cpp 
Cpp :: error when using base class members 
Cpp :: what does map.count() return in c++ 
Cpp :: c to c++ code converter 
Cpp :: Get the absolute path of a boost filePath as a string 
Cpp :: vowel and consonant program in c++ using if else 
Cpp :: pimpl c++ 
Cpp :: . Single-line comments start with two forward slashes (//). 
Cpp :: c++ require keyword 
Cpp :: destiny child 
Cpp :: unions c++ 
Cpp :: c++ sort numbers by magnitude/absolute value 
Cpp :: how to use #define c++ 
Cpp :: c++ enter name and surname one string 
Cpp :: command loop ctrl D c++ 
Cpp :: Runtime error(Exit status:153(File size limit exceeded)) c++ 
Cpp :: libraries required for gaming in c++ 
Cpp :: displaying m images m windows opencv c++ 
Cpp :: do c++ ints neeed to be initlaized 
Cpp :: multiple inheritance c++ 
Cpp :: copy constructor in c++ questions 
Cpp :: convert c to C language 
Cpp :: std 
Cpp :: 16630147 
Cpp :: how to fixed how many digit will be after point in c++ 
Cpp :: how to use printf with microseconds c++ 
Cpp :: polymorphism c++ virtual 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =