Wednesday 4 January 2017

C program to find all substrings of a given string

#include <stdio.h>
#include <string.h>
main()
{
            char name[50];
            int i,j,k,l1;
            gets(name);
            l1=strlen(name);
            for(i=0;i<l1;i++)
            {
                        for(j=0;j<l1;j++)
                        {
                                    for(k=i;k<=j;k++)
                                                printf("%c",name[k]);
                                    printf("\n");
                        }
            }

}

No comments:

Post a Comment