// stringpattern.cpp : Defines the entry point for the console applic
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

void find_subset(char *set, char *subset,int n, int k, int j);
int main()


    {


    //FILE *fd;
    int n,k=0,i;
    char set[100], subset[100],ch;
    ch='A';
    printf("Enter length of the set:");
    scanf("%d",&n);
    printf("Enter the set:");
    for (i = 0; i <n; i++)
    {

        set[i]=ch;
        ch++;
    }
    printf("Enter the value of k(size of subset):");
    scanf("%d",&k);
    find_subset(set, subset, n, k, 0);


    getchar();
    return 0;
`}`
void find_subset(char *set, char *subset,int n, int k, int j)
{
    //FILE *fd;
    int i;
    //fd=fopen("C:/Users/Zahid/Desktop/dslab.txt","w+");
    if (k == 0)
    {
        subset[j]= '\0';
        printf("\n%s",subset);
        return;
    }
    //fclose(fd);
    for(i = 0; i < n; i++)
    {
        subset[j] = set[i];
        find_subset(set, subset, n, k-1, j+1);
    }
}

/// using this code i can generate any number of possible string... but is there any other possible easy way to solve this problem

Jony, it seems that you keep asking us to solve your homework problems for you. We don't do that! Make an honest effort. Post your OWN code. Tell us where you are having difficulties with it. And THEN we might decide to help you. Unfortunately, you have not got off to a good start here with regard to "honest effort"... :-(

but is there any other possible easy way to solve this problem

What problem? You haven't posted the problem. If all you want to do is get an array of N random characters then the code you posted is way too complicated. All you need is a simple loop that calls rand().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.